{"id":27860,"date":"2024-11-24T17:30:59","date_gmt":"2024-11-24T09:30:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27860\/"},"modified":"2024-11-24T17:30:59","modified_gmt":"2024-11-24T09:30:59","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-overlayscrollbars-%e5%ba%93%e6%8e%a7%e5%88%b6-html-%e9%a1%b5%e9%9d%a2%e6%bb%9a%e5%8a%a8%e6%9d%a1%e7%9a%84%e4%bd%8d%e7%bd%ae%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27860\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u9875\u9762\u6eda\u52a8\u6761\u7684\u4f4d\u7f6e\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173132442428220.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u9875\u9762\u6eda\u52a8\u6761\u7684\u4f4d\u7f6e\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u9875\u9762\u6eda\u52a8\u6761\u7684\u4f4d\u7f6e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528 overlayscrollbars \u63a7\u5236 html \u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e<\/strong><\/p>\n<p>\u5728 HTML \u9875\u9762\u4e2d\uff0c\u6eda\u52a8\u6761\u9ed8\u8ba4\u4f1a\u663e\u793a\u5728\u5185\u5bb9\u7684\u6700\u53f3\u4fa7\u6216\u6700\u5e95\u90e8\u3002\u4f46\u662f\uff0c\u6709\u65f6\u6211\u4eec\u5e0c\u671b\u5c06\u6eda\u52a8\u6761\u663e\u793a\u5728\u7279\u5b9a\u7684 div \u4e2d\u6216\u67d0\u4e2a\u4f4d\u7f6e\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u79cd\u65b9\u6cd5\uff0c\u4f7f\u7528 OverlayScrollbars \u5e93\u5b9e\u73b0\u6b64\u529f\u80fd\u3002<\/p>\n<p><strong>OverlayScrollbars \u5e93<\/strong><\/p>\n<p>OverlayScrollbars \u662f\u4e00\u4e2a JavaScript \u5e93\uff0c\u5b83\u9690\u85cf\u4e86\u9ed8\u8ba4\u6eda\u52a8\u6761\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0 div \u6765\u63a7\u5236\u6eda\u52a8\u3002\u7279\u6027\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u7f8e\u89c2\u3001\u53ef\u5b9a\u5236\u5316<\/li>\n<li>\u652f\u6301\u6c34\u5e73\u548c\u5782\u76f4\u6eda\u52a8<\/li>\n<li>\u53ef\u4ee5\u6307\u5b9a\u6eda\u52a8\u6761\u7684\u4f4d\u7f6e<\/li>\n<\/ul>\n<p><strong>\u5b9e\u73b0\u6b65\u9aa4<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u5b89\u88c5 OverlayScrollbars \u5e93\u3002<\/li>\n<li>\u6dfb\u52a0 CSS \u6837\u5f0f\u4ee5\u9690\u85cf\u539f\u59cb\u6eda\u52a8\u6761\u5e76\u5e94\u7528\u5e93\u6837\u5f0f\u3002<\/li>\n<li>\u4f7f\u7528 JavaScript \u521d\u59cb\u5316 OverlayScrollbars\uff0c\u5e76\u6307\u5b9a\u6eda\u52a8\u533a\u57df\u7684 div\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\u4ee3\u7801<\/strong><\/p>\n<pre>&lt;div id=\"my-div\"&gt;&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>#my-div {\n  height: 500px;\n  overflow: hidden;  \/* \u9690\u85cf\u9ed8\u8ba4\u6eda\u52a8\u6761 *\/\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>import OverlayScrollbars from \"overlayscrollbars\/js\/OverlayScrollbars.min.js\";\n\nconst scrollbar = OverlayScrollbars(document.getElementById(\"my-div\"), {\n  overflowBehavior: {\n    x: \"hidden\",  \/* \u6c34\u5e73\u6eda\u52a8\u6761\u9690\u85cf *\/\n    y: \"scroll\"   \/* \u5782\u76f4\u6eda\u52a8\u6761\u663e\u793a *\/\n  },\n  scrollbars: {\n    autoHide: \"l\",  \/* \u9f20\u6807\u79bb\u5f00\u65f6\u81ea\u52a8\u9690\u85cf\u5de6\u4fa7\u6eda\u52a8\u6761 *\/\n    className: \"os-theme-dark\"  \/* \u6eda\u52a8\u6761\u989c\u8272\u4e3b\u9898 *\/\n  }\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6267\u884c\u6b64\u4ee3\u7801\u540e\uff0c\u6eda\u52a8\u6761\u5c06\u663e\u793a\u5728 #my-div \u4e2d\uff0c\u4e14\u6c34\u5e73\u6eda\u52a8\u6761\u5c06\u9690\u85cf\u3002\u4f60\u8fd8\u53ef\u4ee5\u901a\u8fc7 scrollbars \u5bf9\u8c61\u81ea\u5b9a\u4e49\u6eda\u52a8\u6761\u7684\u5916\u89c2\u548c\u884c\u4e3a\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u63a7\u5236 HTML \u9875\u9762\u6eda\u52a8\u6761\u7684\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>\u4f7f\u7528 overlayscrollbars \u63a7\u5236 html \u6eda\u52a8\u6761\u663e\u793a\u4f4d\u7f6e \u5728 HTML \u9875\u9762\u4e2d\uff0c\u6eda\u52a8\u6761\u9ed8\u8ba4\u4f1a\u663e\u793a\u5728\u5185\u5bb9\u7684\u6700\u53f3\u4fa7\u6216\u6700\u5e95\u90e8\u3002\u4f46\u662f\uff0c\u6709\u65f6\u6211\u4eec\u5e0c\u671b\u5c06\u6eda\u52a8\u6761\u663e\u793a\u5728\u7279\u5b9a\u7684 div \u4e2d\u6216\u67d0\u4e2a\u4f4d\u7f6e\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u79cd\u65b9\u6cd5\uff0c\u4f7f\u7528 OverlayScrollbars \u5e93\u5b9e\u73b0\u6b64\u529f\u80fd\u3002 OverlayScrollbars \u5e93 OverlayScrollbars \u662f\u4e00\u4e2a JavaScript \u5e93\uff0c\u5b83\u9690\u85cf\u4e86\u9ed8\u8ba4\u6eda\u52a8\u6761\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0 div \u6765\u63a7\u5236\u6eda\u52a8\u3002\u7279\u6027\u5305\u62ec\uff1a \u7f8e\u89c2\u3001\u53ef\u5b9a\u5236\u5316 \u652f\u6301\u6c34\u5e73\u548c\u5782\u76f4\u6eda\u52a8 \u53ef\u4ee5\u6307\u5b9a\u6eda\u52a8\u6761\u7684\u4f4d\u7f6e \u5b9e\u73b0\u6b65\u9aa4 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5b89\u88c5 OverlayScrollbars \u5e93\u3002 \u6dfb\u52a0 CSS \u6837\u5f0f\u4ee5\u9690\u85cf\u539f\u59cb\u6eda\u52a8\u6761\u5e76\u5e94\u7528\u5e93\u6837\u5f0f\u3002 \u4f7f\u7528 JavaScript \u521d\u59cb\u5316 OverlayScrollbars\uff0c\u5e76\u6307\u5b9a\u6eda\u52a8\u533a\u57df\u7684 div\u3002 \u793a\u4f8b\u4ee3\u7801 &lt;div id=&#8221;my-div&#8221;&gt;&lt;\/div&gt; \u767b\u5f55\u540e\u590d\u5236 #my-div { height: 500px; overflow: hidden; \/* \u9690\u85cf\u9ed8\u8ba4\u6eda\u52a8\u6761 *\/ } \u767b\u5f55\u540e\u590d\u5236 import OverlayScrollbars from &#8220;overlayscrollbars\/js\/OverlayScrollbars.min.js&#8221;; [&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-27860","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27860","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=27860"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27860\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}