{"id":53155,"date":"2024-12-03T09:57:04","date_gmt":"2024-12-03T01:57:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53155\/"},"modified":"2024-12-03T09:57:04","modified_gmt":"2024-12-03T01:57:04","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-scroll-behavior-%e5%b1%9e%e6%80%a7%e5%ae%9e%e7%8e%b0%e5%85%83%e7%b4%a0scrollleft%e5%8f%98%e5%8c%96%e6%97%b6%e7%9a%84%e5%b9%b3%e6%bb%91%e5%8a%a8%e7%94%bb%ef%bc%9f-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53155\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 scroll-behavior \u5c5e\u6027\u5b9e\u73b0\u5143\u7d20scrollLeft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 scroll-behavior \u5c5e\u6027\u5b9e\u73b0\u5143\u7d20scrollLeft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\uff1f<\/h1>\n<p>\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\u5417\uff1f\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u4f7f\u7528 scroll-behavior \u5c5e\u6027\u5b9e\u73b0\u5143\u7d20scrollLeft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\uff1f\u300b<\/span>\uff0c\u4e3b\u8981\u4ecb\u7ecd\u7684\u5185\u5bb9\u5c31\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u5982\u679c\u4f60\u60f3\u63d0\u5347\u81ea\u5df1\u7684\u5f00\u53d1\u80fd\u529b\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5927\u5bb6\u8981\u77e5\u9053\u7f16\u7a0b\u7406\u8bba\u57fa\u7840\u548c\u5b9e\u6218\u64cd\u4f5c\u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u54e6\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241127\/17326964336746d97188eb9.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 scroll-behavior \u5c5e\u6027\u5b9e\u73b0\u5143\u7d20scrollLeft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 scroll-behavior \u5c5e\u6027\u5b9e\u73b0\u5143\u7d20scrollLeft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0\u5143\u7d20scrollleft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\u6548\u679c\uff1f<\/strong><\/p>\n<p>\u5728\u8bb8\u591a\u7f51\u9875\u5e94\u7528\u4e2d\uff0c\u6eda\u52a8\u5bb9\u5668\u7684\u6c34\u5e73\u6eda\u52a8\u6761\uff08scrollleft\uff09\u9700\u8981\u9891\u7e41\u4f7f\u7528\u3002\u4e3a\u4e86\u8ba9\u6eda\u52a8\u52a8\u4f5c\u66f4\u52a0\u81ea\u7136\uff0c\u4f60\u5e0c\u671b\u7ed9scrollleft\u7684\u53d8\u5316\u6dfb\u52a0\u52a8\u753b\u6548\u679c\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1ascroll-behavior \u5c5e\u6027<\/strong><\/p>\n<p>\u8981\u5b9e\u73b0scrollleft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\u6548\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 css \u7684 scroll-behavior \u5c5e\u6027\u3002\u8be5\u5c5e\u6027\u5141\u8bb8\u4f60\u63a7\u5236\u6eda\u52a8\u884c\u4e3a\u7684\u5e73\u6ed1\u5ea6\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 scroll-behavior \u5b9e\u73b0\u5e73\u6ed1\u6eda\u52a8\u6548\u679c\u7684\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;div id=\"container\"&gt;\n  &lt;div id=\"content\"&gt;click the button to slide right!&lt;\/div&gt;\n&lt;\/div&gt;\n\n&lt;button id=\"slide\" type=\"button\"&gt;slide right&lt;\/button&gt;<\/pre>\n<pre>#container {\n  width: 100px;\n  height: 100px;\n  border: 1px solid #ccc;\n  overflow-x: scroll;\n  scroll-behavior: smooth;\n}\n\n#content {\n  width: 250px;\n  background-color: #ccc;\n}<\/pre>\n<pre>const button = document.getElementById(\"slide\");\n\nbutton.onclick = function() {\n  document.getElementById(\"container\").scrollLeft += 20;\n};<\/pre>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c#container \u662f\u6eda\u52a8\u5bb9\u5668\uff0c\u800c #content \u662f\u53ef\u6eda\u52a8\u7684\u5185\u5bb9\u3002\u5f53\u5355\u51fb &#8220;slide right&#8221; \u6309\u94ae\u65f6\uff0c#container \u7684 scrollleft \u503c\u4f1a\u589e\u52a0 20\uff0c\u4ece\u800c\u5e73\u6ed1\u5730\u5411\u53f3\u6eda\u52a8\u5185\u5bb9\u3002<\/p>\n<p>\u901a\u8fc7\u4f7f\u7528 scroll-behavior \u5c5e\u6027\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u4e3a\u5143\u7d20\u6dfb\u52a0\u5e73\u6ed1\u7684scrollleft\u52a8\u753b\u6548\u679c\uff0c\u4ece\u800c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u4f7f\u7528Prisma\u64cd\u4f5c\u817e\u8baf\u4e91MySQL\u6570\u636e\u5e93\u65f6\uff0c\u65f6\u95f4\u5dee8\u5c0f\u65f6\u600e\u4e48\u529e\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 scroll-behavior \u5c5e\u6027\u5b9e\u73b0\u5143\u7d20scrollLeft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\uff1f \u4f60\u5728\u5b66\u4e60\u6587\u7ae0\u76f8\u5173\u7684\u77e5\u8bc6\u5417\uff1f\u672c\u6587\u300a\u5982\u4f55\u4f7f\u7528 scroll-behavior \u5c5e\u6027\u5b9e\u73b0\u5143\u7d20scrollLeft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u7684\u5185\u5bb9\u5c31\u6d89\u53ca\u5230\uff0c\u5982\u679c\u4f60\u60f3\u63d0\u5347\u81ea\u5df1\u7684\u5f00\u53d1\u80fd\u529b\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5927\u5bb6\u8981\u77e5\u9053\u7f16\u7a0b\u7406\u8bba\u57fa\u7840\u548c\u5b9e\u6218\u64cd\u4f5c\u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u54e6\uff01 \u5982\u4f55\u5b9e\u73b0\u5143\u7d20scrollleft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\u6548\u679c\uff1f \u5728\u8bb8\u591a\u7f51\u9875\u5e94\u7528\u4e2d\uff0c\u6eda\u52a8\u5bb9\u5668\u7684\u6c34\u5e73\u6eda\u52a8\u6761\uff08scrollleft\uff09\u9700\u8981\u9891\u7e41\u4f7f\u7528\u3002\u4e3a\u4e86\u8ba9\u6eda\u52a8\u52a8\u4f5c\u66f4\u52a0\u81ea\u7136\uff0c\u4f60\u5e0c\u671b\u7ed9scrollleft\u7684\u53d8\u5316\u6dfb\u52a0\u52a8\u753b\u6548\u679c\u3002 \u89e3\u51b3\u65b9\u6848\uff1ascroll-behavior \u5c5e\u6027 \u8981\u5b9e\u73b0scrollleft\u53d8\u5316\u65f6\u7684\u5e73\u6ed1\u52a8\u753b\u6548\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 css \u7684 scroll-behavior \u5c5e\u6027\u3002\u8be5\u5c5e\u6027\u5141\u8bb8\u4f60\u63a7\u5236\u6eda\u52a8\u884c\u4e3a\u7684\u5e73\u6ed1\u5ea6\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 scroll-behavior \u5b9e\u73b0\u5e73\u6ed1\u6eda\u52a8\u6548\u679c\u7684\u4ee3\u7801\u793a\u4f8b\uff1a &lt;div id=&#8221;container&#8221;&gt; &lt;div id=&#8221;content&#8221;&gt;click the button to slide right!&lt;\/div&gt; &lt;\/div&gt; &lt;button id=&#8221;slide&#8221; type=&#8221;button&#8221;&gt;slide right&lt;\/button&gt; #container { width: 100px; height: 100px; border: 1px solid #ccc; overflow-x: scroll; scroll-behavior: smooth; } #content { width: 250px; background-color: #ccc; } 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-53155","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53155","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=53155"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53155\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}