{"id":27849,"date":"2024-11-24T17:37:53","date_gmt":"2024-11-24T09:37:53","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27849\/"},"modified":"2024-11-24T17:37:53","modified_gmt":"2024-11-24T09:37:53","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-overlayscrollbars-%e5%ba%93%e6%8e%a7%e5%88%b6-html-%e6%bb%9a%e5%8a%a8%e6%9d%a1%e6%98%be%e7%a4%ba%e4%bd%8d%e7%bd%ae%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27849\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173132352558519.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u63a7\u5236\u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e<\/strong><\/p>\n<p>\u95ee\u9898\uff1a\u5982\u4f55\u5728 HTML \u4e2d\u63a7\u5236\u6eda\u52a8\u6761\u663e\u793a\u7684\u4f4d\u7f6e\uff0c\u4f7f\u5176\u663e\u793a\u5728\u7279\u5b9a div \u5185\u6216\u7279\u5b9a\u4f4d\u7f6e\uff1f<\/p>\n<p>\u56de\u7b54\uff1a<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 OverlayScrollbars \u5e93\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u8be5\u5e93\u53ef\u4ee5\u9690\u85cf\u9ed8\u8ba4\u6eda\u52a8\u6761\uff0c\u5e76\u5b9a\u4e49\u4e00\u4e2a div \u6765\u63a7\u5236\u6eda\u52a8\u3002<\/p>\n<p><strong>\u4f7f\u7528 OverlayScrollbars \u5e93<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\n<p>\u5bfc\u5165 OverlayScrollbars \u5e93\uff1a<\/p>\n<pre>&lt;script src=\"path\/to\/overlayScrollbars.min.js\"&gt;&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u521d\u59cb\u5316\u6eda\u52a8\u6761\uff1a<\/p>\n<pre>const myScrollbar = OverlayScrollbars(document.querySelector('.my-div'), {\n  className: 'os-theme-light', \/\/ \u8bbe\u7f6e\u4e3b\u9898\n  scrollbars: {\n autoHide: 'move', \/\/ \u81ea\u52a8\u9690\u85cf\u6eda\u52a8\u6761\n  },\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u8bbe\u7f6e\u6eda\u52a8\u6761\u4f4d\u7f6e\uff1a<\/p>\n<pre>myScrollbar.scroll({\n  x: 100, \/\/ \u8bbe\u7f6e\u6c34\u5e73\u6eda\u52a8\u6761\u4f4d\u7f6e\n  y: 200, \/\/ \u8bbe\u7f6e\u5782\u76f4\u6eda\u52a8\u6761\u4f4d\u7f6e\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u5c06\u521b\u5efa\u4e00\u4e2a div \u5e76\u4f7f\u7528 OverlayScrollbars \u63a7\u5236\u5176\u6eda\u52a8\u6761\uff1a<\/p>\n<pre>&lt;div class=\"my-div\" style=\"width: 500px; height: 500px; overflow: auto;\"&gt;\n  &lt;!-- \u5185\u5bb9 --&gt;\n&lt;\/div&gt;\n\n&lt;script&gt;\n  const myScrollbar = OverlayScrollbars(document.querySelector('.my-div'), {\n    className: 'os-theme-light',\n    scrollbars: {\n      autoHide: 'move',\n    },\n  });\n\n  myScrollbar.scroll({\n    x: 100,\n    y: 200,\n  });\n&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a7\u5236\u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e \u95ee\u9898\uff1a\u5982\u4f55\u5728 HTML \u4e2d\u63a7\u5236\u6eda\u52a8\u6761\u663e\u793a\u7684\u4f4d\u7f6e\uff0c\u4f7f\u5176\u663e\u793a\u5728\u7279\u5b9a div \u5185\u6216\u7279\u5b9a\u4f4d\u7f6e\uff1f \u56de\u7b54\uff1a \u53ef\u4ee5\u4f7f\u7528 OverlayScrollbars \u5e93\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u8be5\u5e93\u53ef\u4ee5\u9690\u85cf\u9ed8\u8ba4\u6eda\u52a8\u6761\uff0c\u5e76\u5b9a\u4e49\u4e00\u4e2a div \u6765\u63a7\u5236\u6eda\u52a8\u3002 \u4f7f\u7528 OverlayScrollbars \u5e93 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5bfc\u5165 OverlayScrollbars \u5e93\uff1a &lt;script src=&#8221;path\/to\/overlayScrollbars.min.js&#8221;&gt;&lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u521d\u59cb\u5316\u6eda\u52a8\u6761\uff1a const myScrollbar = OverlayScrollbars(document.querySelector(&#8216;.my-div&#8217;), { className: &#8216;os-theme-light&#8217;, \/\/ \u8bbe\u7f6e\u4e3b\u9898 scrollbars: { autoHide: &#8216;move&#8217;, \/\/ \u81ea\u52a8\u9690\u85cf\u6eda\u52a8\u6761 }, }); \u767b\u5f55\u540e\u590d\u5236 \u8bbe\u7f6e\u6eda\u52a8\u6761\u4f4d\u7f6e\uff1a myScrollbar.scroll({ x: 100, \/\/ \u8bbe\u7f6e\u6c34\u5e73\u6eda\u52a8\u6761\u4f4d\u7f6e y: 200, \/\/ \u8bbe\u7f6e\u5782\u76f4\u6eda\u52a8\u6761\u4f4d\u7f6e }); \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b \u4ee5\u4e0b\u793a\u4f8b\u5c06\u521b\u5efa\u4e00\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27849","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=27849"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27849\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}