{"id":52515,"date":"2024-12-03T08:24:23","date_gmt":"2024-12-03T00:24:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52515\/"},"modified":"2024-12-03T08:24:23","modified_gmt":"2024-12-03T00:24:23","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-overlayscrollbars-%e5%ba%93%e5%b0%86%e7%bd%91%e9%a1%b5%e6%bb%9a%e5%8a%a8%e6%9d%a1%e5%ae%9a%e4%bd%8d%e5%88%b0%e7%89%b9%e5%ae%9a-div-%e5%8c%ba%e5%9f%9f%e5%86%85-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52515\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f <\/h1>\n<p>\u201c\u7eb5\u6709\u75be\u98ce\u6765\uff0c\u4eba\u751f\u4e0d\u8a00\u5f03\u201d\uff0c\u8fd9\u53e5\u8bdd\u9001\u7ed9\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u7684\u670b\u53cb\u4eec\uff0c\u4e5f\u5e0c\u671b\u5728\u9605\u8bfb\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f \u300b<\/span>\u540e\uff0c\u80fd\u591f\u771f\u7684\u5e2e\u52a9\u5230\u5927\u5bb6\u3002\u6211\u4e5f\u4f1a\u5728\u540e\u7eed\u7684\u6587\u7ae0\u4e2d\uff0c\u9646\u7eed\u66f4\u65b0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u7684\u6280\u672f\u6587\u7ae0\uff0c\u6709\u597d\u7684\u5efa\u8bae\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u975e\u5e38\u611f\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241121\/1732157506673ea042a6da8.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>HTML \u4e2d\u5b9a\u4f4d\u6eda\u52a8\u6761\u5230\u7279\u5b9a div<\/strong><\/p>\n<p>\u5982\u4f55\u5c06\u7f51\u9875\u4e2d\u7684\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a\u7684 div \u533a\u57df\u5185\uff1f<\/p>\n<p><strong>\u7b54\u6848\uff1a<\/strong><\/p>\n<p>\u8981\u60f3\u5b9e\u73b0\u6eda\u52a8\u6761\u663e\u793a\u5728\u7279\u5b9a div \u533a\u57df\u5185\uff0c\u800c\u4e0d\u662f\u6d4f\u89c8\u5668\u7a97\u53e3\u6700\u53f3\u4fa7\u6216\u6700\u5e95\u90e8\uff0c\u53ef\u4ee5\u4f7f\u7528 OverlayScrollbars \u5e93\u3002<\/p>\n<p><strong>OverlayScrollbars \u5e93<\/strong><\/p>\n<p>OverlayScrollbars \u5e93\u63d0\u4f9b\u4e86\u4e00\u79cd\u8de8\u6d4f\u89c8\u5668\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u9690\u85cf\u4e86\u9ed8\u8ba4\u6eda\u52a8\u6761\uff0c\u5e76\u4f7f\u7528\u4e00\u4e2a div \u5143\u7d20\u6765\u63a7\u5236\u6eda\u52a8\u884c\u4e3a\u3002<\/p>\n<p><strong>\u5b9e\u73b0\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u5b89\u88c5 OverlayScrollbars \u5e93\uff1a<\/li>\n<\/ol>\n<pre>npm install overlay-scrollbars<\/pre>\n<ol>\n<li>\u5728 HTML \u4e2d\u6dfb\u52a0\u8981\u6eda\u52a8\u533a\u57df\u7684 div \u5143\u7d20\uff1a<\/li>\n<\/ol>\n<pre>&lt;div id=\"scrollbar-container\"&gt;\n  &lt;!-- \u8fd9\u91cc\u653e\u9700\u8981\u6eda\u52a8\u7684\u5185\u5bb9 --&gt;\n&lt;\/div&gt;<\/pre>\n<ol>\n<li>\u5bfc\u5165 OverlayScrollbars \u811a\u672c\u5e76\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\uff1a<\/li>\n<\/ol>\n<pre>import OverlayScrollbars from 'overlayscrollbars';\n\nconst scrollContainer = document.getElementById('scrollbar-container');\n\nconst options = {\n  className: 'os-theme-light'  \/\/ \u6eda\u52a8\u6761\u6837\u5f0f\u4e3b\u9898\uff08\u53ef\u9009\uff09\n};\n\nOverlayScrollbars(scrollContainer, options);<\/pre>\n<p>\u521d\u59cb\u5316\u4e4b\u540e\uff0c\u6eda\u52a8\u6761\u5c06\u663e\u793a\u5728\u6307\u5b9a\u7684 div \u5143\u7d20\u5185\uff0c\u4ece\u800c\u63d0\u4f9b\u66f4\u7cbe\u7ec6\u7684\u6eda\u52a8\u63a7\u5236\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f \u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u4f7f\u7528\u53d8\u91cf\u7ed3\u5408\u5a92\u4f53\u67e5\u8be2\u65f6\u8c03\u8282\u7ec4\u4ef6\u5185\u8fb9\u8ddd\u4e0d\u8d77\u4f5c\u7528\u7684\u539f\u56e0\u548c\u89e3\u51b3\u65b9\u6cd5\u662f\u4ec0\u4e48\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f \u201c\u7eb5\u6709\u75be\u98ce\u6765\uff0c\u4eba\u751f\u4e0d\u8a00\u5f03\u201d\uff0c\u8fd9\u53e5\u8bdd\u9001\u7ed9\u6b63\u5728\u5b66\u4e60\u6587\u7ae0\u7684\u670b\u53cb\u4eec\uff0c\u4e5f\u5e0c\u671b\u5728\u9605\u8bfb\u672c\u6587\u300a\u5982\u4f55\u4f7f\u7528 OverlayScrollbars \u5e93\u5c06\u7f51\u9875\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a div \u533a\u57df\u5185\uff1f \u300b\u540e\uff0c\u80fd\u591f\u771f\u7684\u5e2e\u52a9\u5230\u5927\u5bb6\u3002\u6211\u4e5f\u4f1a\u5728\u540e\u7eed\u7684\u6587\u7ae0\u4e2d\uff0c\u9646\u7eed\u66f4\u65b0\u6587\u7ae0\u76f8\u5173\u7684\u6280\u672f\u6587\u7ae0\uff0c\u6709\u597d\u7684\u5efa\u8bae\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u975e\u5e38\u611f\u8c22\uff01 HTML \u4e2d\u5b9a\u4f4d\u6eda\u52a8\u6761\u5230\u7279\u5b9a div \u5982\u4f55\u5c06\u7f51\u9875\u4e2d\u7684\u6eda\u52a8\u6761\u5b9a\u4f4d\u5230\u7279\u5b9a\u7684 div \u533a\u57df\u5185\uff1f \u7b54\u6848\uff1a \u8981\u60f3\u5b9e\u73b0\u6eda\u52a8\u6761\u663e\u793a\u5728\u7279\u5b9a div \u533a\u57df\u5185\uff0c\u800c\u4e0d\u662f\u6d4f\u89c8\u5668\u7a97\u53e3\u6700\u53f3\u4fa7\u6216\u6700\u5e95\u90e8\uff0c\u53ef\u4ee5\u4f7f\u7528 OverlayScrollbars \u5e93\u3002 OverlayScrollbars \u5e93 OverlayScrollbars \u5e93\u63d0\u4f9b\u4e86\u4e00\u79cd\u8de8\u6d4f\u89c8\u5668\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u9690\u85cf\u4e86\u9ed8\u8ba4\u6eda\u52a8\u6761\uff0c\u5e76\u4f7f\u7528\u4e00\u4e2a div \u5143\u7d20\u6765\u63a7\u5236\u6eda\u52a8\u884c\u4e3a\u3002 \u5b9e\u73b0\u6b65\u9aa4\uff1a \u5b89\u88c5 OverlayScrollbars \u5e93\uff1a npm install overlay-scrollbars \u5728 HTML \u4e2d\u6dfb\u52a0\u8981\u6eda\u52a8\u533a\u57df\u7684 div \u5143\u7d20\uff1a &lt;div id=&#8221;scrollbar-container&#8221;&gt; &lt;!&#8211; \u8fd9\u91cc\u653e\u9700\u8981\u6eda\u52a8\u7684\u5185\u5bb9 &#8211;&gt; &lt;\/div&gt; \u5bfc\u5165 OverlayScrollbars \u811a\u672c\u5e76\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\uff1a import OverlayScrollbars from &#8216;overlayscrollbars&#8217;; const [&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-52515","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52515","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=52515"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52515\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}