{"id":3239,"date":"2024-06-14T09:31:29","date_gmt":"2024-06-14T01:31:29","guid":{"rendered":"https:\/\/www.yuan95.cn\/?p=3239"},"modified":"2025-01-01T15:07:53","modified_gmt":"2025-01-01T07:07:53","slug":"%e7%bd%91%e9%a1%b5%e8%bd%ae%e6%92%ad%e5%9b%be%e4%bb%a3%e7%a0%81%ef%bc%88htmlcssjs-%e9%99%84%e6%ba%90%e7%a0%81%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.yuan95.cn\/?p=3239","title":{"rendered":"\u7f51\u9875\u8f6e\u64ad\u56fe\u4ee3\u7801\uff08HTML+CSS+JS, \u9644\u6e90\u7801\uff09"},"content":{"rendered":"<p>\u4e0b\u9762\u5c31\u662f\u6f14\u793a\u6548\u679c\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0b\u9762\u662f\u4ee3\u7801\u3002\u9700\u8981\u81ea\u5df1\u628a&lt;img src=&#8221;2.png&#8221; style=&#8221;background-color: bisque;&#8221;&gt; \u4ee3\u7801\u4e2d\u76842.png\uff0c\u6362\u6210\u81ea\u5df1\u7684\u56fe\u7247\u8def\u5f84\u3002<\/p>\n<pre>&lt;!DOCTYPE html&gt; &lt;html lang=\"en\"&gt; &lt;head&gt; &lt;meta charset=\"UTF-8\"&gt; &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt; &lt;title&gt;\u8f6e\u64ad\u56fe&lt;\/title&gt; &lt;style&gt; *{ margin: 0; padding: 0; text-decoration: none; list-style: none; background-repeat: no-repeat; } .carousel { position: relative; width: 100%; overflow: hidden; } .carousel-inner { display: flex; width: 100%; transition: transform 0.6s ease-in-out; } .item { flex: 0 0 100%; height: 55vh; } .item img { width: 100%; height: 100%; object-fit: cover; } .carousel-control { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 80px; z-index: 10; cursor: pointer; } .left { left: 25px; } .right { right: 25px; } .dots { position: absolute; bottom: 20px; left: 50%; z-index: 15; width: 60%; padding-left: 0; margin-left: -30%; text-align: center; list-style: none; } .dots &gt; li { display: inline-block; width: 10px; height: 10px; margin: 1px; cursor: pointer; background-color: rgba(0,0,0,0); border: 1px solid #fff; border-radius: 10px; } .dots .active { width: 12px; height: 12px; margin: 0; background-color: #fff; } &lt;\/style&gt; &lt;\/head&gt; &lt;body&gt; &lt;div class=\"carousel\" id=\"carousel\"&gt; &lt;div class=\"carousel-inner\"&gt; &lt;div class=\"item\"&gt; &lt;img src=\"1.png\" style=\"background-color: pink;\"&gt; &lt;\/div&gt; &lt;div class=\"item\"&gt; &lt;img src=\"2.png\" style=\"background-color: bisque;\"&gt; &lt;\/div&gt; &lt;div class=\"item\"&gt; &lt;img src=\"3.jpg\" style=\"background-color: rgb(144, 255, 236);\"&gt; &lt;\/div&gt; &lt;div class=\"item\"&gt; &lt;img src=\"4.jpg\" style=\"background-color: rgb(248, 99, 124);\"&gt; &lt;\/div&gt; &lt;div class=\"item\"&gt; &lt;img src=\"5.jpg\" style=\"background-color: rgb(210, 161, 250);\"&gt; &lt;\/div&gt; &lt;\/div&gt; &lt;div class=\"carousel-control left\" onclick=\"prevSlide()\"&gt;&amp;lsaquo;&lt;\/div&gt; &lt;div class=\"carousel-control right\" onclick=\"nextSlide()\"&gt;&amp;rsaquo;&lt;\/div&gt; &lt;div class=\"dots\"&gt; &lt;li class=\"active\" onclick=\"jumpToSlide(0)\"&gt;&lt;\/li&gt; &lt;li onclick=\"jumpToSlide(1)\"&gt;&lt;\/li&gt; &lt;li onclick=\"jumpToSlide(2)\"&gt;&lt;\/li&gt; &lt;li onclick=\"jumpToSlide(3)\"&gt;&lt;\/li&gt; &lt;li onclick=\"jumpToSlide(4)\"&gt;&lt;\/li&gt; &lt;\/div&gt; &lt;\/div&gt; &lt;\/body&gt; &lt;script&gt; let items = document.querySelectorAll('.item'); let current = 0; function showSlide() { items.forEach(item =&gt; { item.style.transform = `translateX(-${current * 100}%)`; }); updateDots(); } function prevSlide() { if (current &gt; 0) { current--; } else { current = items.length - 1; } showSlide(); } function nextSlide() { if (current &lt; items.length - 1) { current++; } else { current = 0; } showSlide(); } let timer = setInterval(nextSlide, 3000); function pauseTimer() { clearInterval(timer); } function resumeTimer() { timer = setInterval(nextSlide, 3000); } document.getElementById('carousel').addEventListener('mouseover', pauseTimer); document.getElementById('carousel').addEventListener('mouseout', resumeTimer); let dots = document.querySelectorAll('.dots li'); function updateDots() { dots.forEach(dot =&gt; { dot.classList.remove('active'); }); dots[current].classList.add('active'); } function jumpToSlide(index) { current = index; showSlide(); updateDots(); } &lt;\/script&gt; &lt;\/html&gt;<\/pre>\n<p>\u9700\u8981\u81ea\u5df1\u628a&lt;li&gt;&lt;img src=&#8221;1.jpg&#8221; alt=&#8221;&#8221; \/&gt;&lt;\/li&gt;\u4e2d\u76842.png\uff0c\u6362\u6210\u81ea\u5df1\u7684\u56fe\u7247\u8def\u5f84\u3002<\/p>\n<pre>&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n\r\n&lt;head&gt;\r\n&lt;meta charset=\"UTF-8\"&gt;\r\n&lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;\r\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n&lt;title&gt;\u8dd1\u9a6c\u706f\u8f6e\u64ad\u56fe&lt;\/title&gt;\r\n&lt;style&gt;\r\n* {\r\nmargin: 0;\r\npadding: 0;\r\n}\r\n.carousel {\r\nwidth: 650px;\r\nmargin: 50px auto;\r\nposition: relative;\r\noverflow: hidden;\r\n\/* \u8d85\u51fa\u90e8\u5206\u9690\u85cf *\/\r\n}\r\n\/* \u6807\u9898-\u8f6e\u64ad\u56fe *\/\r\nh1 {\r\ntext-align: center;\r\n}\r\n.carousel ul {\r\nlist-style: none;\r\n\/* \u6d88\u9664ul\u81ea\u5e26\u5706\u70b9 *\/\r\n}\r\n.carousel #list {\r\nwidth: 6000px;\r\nposition: relative;\r\nleft: 0px;\r\n\/* \u521d\u59cb\u4f4d\u7f6e *\/\r\ntransition: left 0.5s ease 0s;\r\n\/*\u56fe\u7247\u8df3\u8f6c\u7684\u8fc7\u6e21\u6548\u679c*\/\r\n}\r\n.carousel #list img {\r\nwidth: 650px;\r\n}\r\n.carousel #list li {\r\nfloat: left;\r\n\/* li\u6392\u6210\u4e00\u6392\u663e\u793a *\/\r\n}\r\n\/* \u4e0a\u4e00\u5f20\/\u4e0b\u4e00\u5f20\u63a7\u5236\u6309\u94ae *\/\r\n.carousel&gt;a {\r\nposition: absolute;\r\nwidth: 30px;\r\nheight: 50px;\r\n\/* \u5782\u76f4\u5c45\u4e2d\uff0c\u8ddd\u9876\u90e8\u4e00\u534a\u7684\u7236\u5143\u7d20\u76d2\u5b50\u5bbd\u5ea6\uff0c\u518d\u5411\u4e0a\u79fb\u52a8\u81ea\u8eab\u7684\u4e00\u534a *\/\r\ntop: 50%;\r\nmargin-top: -25px;\r\nbackground-color: rgba(163, 166, 167, 0.5);\r\n}\r\n.carousel&gt;a&gt;img {\r\nmargin-left: -8px;\r\n}\r\n.carousel .leftbtn {\r\nleft: 20px;\r\n}\r\n.carousel .rightbtn {\r\nright: 20px;\r\n}\r\n\/* \u5e95\u90e8\u5b9a\u4f4d\u5706\u70b9list *\/\r\n.carousel #location_list {\r\nwidth: 120px;\r\nposition: absolute;\r\ntop: 350px;\r\nleft: 270px;\r\n}\r\n.carousel #location_list li {\r\nfloat: left;\r\nwidth: 10px;\r\nheight: 10px;\r\nborder-radius: 50%;\r\nmargin: 5px;\r\nborder: 1px solid white;\r\n}\r\n\/* \u5706\u70b9\u88ab\u6fc0\u6d3b\u65f6\u7684\u6837\u5f0f\uff0c\u52a8\u6001\u4e3a\u5706\u70b9\u589e\u52a0class *\/\r\n.carousel #location_list li.active {\r\nbackground-color: bisque;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n&lt;h1&gt;\u8f6e\u64ad\u56fe&lt;\/h1&gt;\r\n&lt;div class=\"carousel\"&gt;\r\n&lt;!--\u56fe\u7247\u5217\u8868 --&gt;\r\n&lt;ul id=\"list\"&gt;\r\n&lt;li&gt;&lt;img src=\" 380x268.jpg\" alt=\"\" \/&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;img src=\"1.jpg\" alt=\"\" \/&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;img src=\"2.jpg\" alt=\"\" \/&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;img src=\"images\/number\/4.jpg\" alt=\"\" \/&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;img src=\"images\/number\/5.jpg\" alt=\"\" \/&gt;&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n&lt;!-- \u5de6\u53f3\u6309\u94ae --&gt;\r\n&lt;a href=\"javascript:;\" class=\"leftbtn\"&gt;&lt;img src=\".\/images\/lunbo\/chevron-left.png\" alt=\"\" srcset=\"\"&gt;&lt;\/a&gt;\r\n&lt;a href=\"javascript:;\" class=\"rightbtn\"&gt;&lt;img src=\".\/images\/lunbo\/chevron-right.png\" alt=\"\" srcset=\"\"&gt;&lt;\/a&gt;\r\n&lt;!-- \u5706\u70b9\u5217\u8868 --&gt;\r\n&lt;ul id=\"location_list\"&gt;\r\n&lt;!-- \u9ed8\u8ba4\u6fc0\u6d3b\u7b2c\u4e00\u4e2a --&gt;\r\n&lt;li class=\"active\"&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n&lt;\/div&gt;\r\n&lt;script&gt;\r\nvar carousel = document.querySelector(\".carousel\");\r\n\/\/ \u83b7\u53d6\u56fe\u7247\u5217\u8868ul\r\nvar olist = document.getElementById(\"list\");\r\n\/\/ \u83b7\u53d6\u5b9a\u4f4d\u6570\u7ec4\r\nvar location_list = document.querySelectorAll('#location_list&gt;li');\r\n\r\n\/\/ \u5411\u5de6\u6309\u94ae\r\nvar leftbtn = document.querySelector('.leftbtn');\r\n\/\/ \u5411\u53f3\u6309\u94ae\r\nvar rightbtn = document.querySelector('.rightbtn');\r\n\r\n\/\/ \u5c06\u7b2c\u4e00\u5f20\u56fe\u7247\u52a0\u5230\u6700\u540e\u4e00\u5f20\uff0c\u65b9\u4fbf\u5faa\u73af\r\nvar oli = document.querySelector(\"#list li:first-child\")\r\nolist.innerHTML += oli.innerHTML;\r\n\r\n\/\/ \u5f53\u524d\u663e\u793a\u7684\u56fe\u7247\u5b9a\u4f4d\r\nvar img_location = 0;\r\n\/\/ \u5f53\u524d\u7684\u5706\u70b9\u5b9a\u4f4d\r\nvar dot_location = 0\r\n\/\/ \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u5b9a\u65f6\u5668\u53d8\u91cf\r\nvar timer = null;\r\n\/\/ \u9ed8\u8ba4\u4e0d\u4e0a\u9501\uff0c\u8be5\u72b6\u6001\u4e3a\u4e86\u4fdd\u8bc1\u8fc7\u6e21\u6548\u679c\u80fd\u5b8c\u6574\u5448\u73b0\r\nvar islock = false;\r\n\r\n\/\/ \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u51fd\u6570\uff0c\u81ea\u52a8\u8df3\u5230\u4e0b\u4e00\u5f20\uff0c\u65b9\u4fbf\u9f20\u6807\u79fb\u5165\u79fb\u51fa\u65f6\u8c03\u7528\r\nfunction move() {\r\ntimer = setInterval(function () {\r\n\/\/ \u6bcf\u96941s\u70b9\u51fb\u5411\u53f3\u6309\u94ae \r\nrightbtn.click();\r\n}, 1000)\r\n}\r\n\/\/ \u9875\u9762\u52a0\u8f7d\u540e\u81ea\u52a8\u8c03\u7528\uff0c\u5b9e\u73b0\u81ea\u52a8\u8df3\u8f6c\u4e0b\u4e00\u5f20\r\nmove();\r\n\r\n\/\/ \u9f20\u6807\u79fb\u5165\uff0c\u6e05\u9664\u5b9a\u65f6\u5668\r\ncarousel.onmouseenter = function () {\r\nclearInterval(timer);\r\n}\r\n\/\/ \u9f20\u6807\u79fb\u51fa\uff0c\u8c03\u7528\u81ea\u52a8\u64ad\u653e\r\ncarousel.onmouseleave = function () {\r\nmove();\r\n}\r\n\r\n\r\n\/\/ \u70b9\u51fb\u6309\u94ae\u5207\u6362\u4e0b\u4e00\u5f20\r\nrightbtn.onclick = function () {\r\nif (islock) { return; }\r\nislock = true;\r\nif (img_location === 5) {\r\n\/\/ \u6e05\u9664\u8fc7\u6e21\u6548\u679c\uff0c\u4ece\u6700\u540e\u4e00\u5f20\u65e0\u7f1d\u8854\u63a5\u5230\u5f00\u5934\r\nolist.style.transition = \"none\";\r\nolist.style.left = \"0px\";\r\nimg_location = 0;\r\n}\r\n\/\/ \u7531\u4e8e\u4ee3\u7801\u6267\u884c\u8fc7\u5feb\uff0c\u6240\u4ee5\u9700\u8981\u653e\u5230\u5f02\u6b65\u6267\u884c\u8bed\u53e5\u91cc\r\nsetTimeout(function () {\r\n\/\/ \u8df3\u5230\u7b2c\u4e8c\u5f20\r\nimg_location += 1;\r\ndot_location += 1;\r\nolist.style.left = -650 * img_location + \"px\";\r\nolist.style.transition = \"left 0.5s ease 0s\";\r\n\/\/ \u5982\u679c\u8df3\u8f6c\u540e\u662f\u7b2c6\u5f20\u56fe\u7247\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u7b2c\u4e00\u5f20\u56fe\uff0c\u5706\u70b9\u5e94\u8be5\u5b9a\u4f4d\u5728\u7b2c1\u4e2a\r\nif (img_location === 5) {\r\ndot_location = 0;\r\nlocation_list[dot_location].className = \"active\";\r\nlocation_list[4].className = \"none\";\r\n} else {\r\n\/\/ \u6fc0\u6d3b\u5f53\u524d\u5b9a\u4f4d\u7684\u5706\u70b9\r\nlocation_list[dot_location].className = \"active\";\r\n\/\/ \u4e0a\u4e00\u4e2a\u5706\u70b9\u53d6\u6d88\u6fc0\u6d3b\u72b6\u6001\r\nlocation_list[dot_location - 1].className = \"none\"\r\n}\r\n\r\n}, 0)\r\nsetTimeout(function () {\r\nislock = false;\r\n}, 500)\r\n};\r\n\r\n\/\/ \u70b9\u51fb\u6309\u94ae\u5207\u6362\u4e0a\u4e00\u5f20\r\nleftbtn.onclick = function () {\r\nif (islock) { return; }\r\nislock = true;\r\n\/\/ \u6e05\u9664\u8fc7\u6e21\u6548\u679c\uff0c\u4ece\u7b2c\u4e00\u5f20\u65e0\u7f1d\u8854\u63a5\u5230\u6700\u540e\u4e00\u5f20\r\nif (img_location === 0) {\r\nimg_location = 5;\r\nolist.style.transition = \"none\";\r\nolist.style.left = -650 * img_location + \"px\";\r\n}\r\n\/\/ \u7531\u4e8e\u4ee3\u7801\u6267\u884c\u8fc7\u5feb\uff0c\u6240\u4ee5\u9700\u8981\u653e\u5230\u5f02\u6b65\u6267\u884c\u8bed\u53e5\u91cc\r\nsetTimeout(function () {\r\n\/\/ \u8df3\u5230\u4e0a\u4e00\u5f20\u56fe\r\nimg_location -= 1;\r\ndot_location -= 1;\r\nolist.style.transition = \"left 0.5s ease 0s\";\r\nolist.style.left = -650 * img_location + \"px\";\r\n\/\/ \u5982\u679c\u8df3\u5b8c\u540e\u662f\u7b2c\u4e94\u5f20\u56fe\uff0c\u5706\u70b9\u4f4d\u7f6e\u4e5f\u8981\u76f8\u5e94\u53d8\u6210\u6700\u540e\u4e00\u4e2a\r\nif (img_location === 4) {\r\ndot_location = 4;\r\nlocation_list[dot_location].className = \"active\";\r\nlocation_list[0].className = \"none\";\r\n} else {\r\nlocation_list[dot_location].className = \"active\";\r\nlocation_list[dot_location + 1].className = \"none\"\r\n}\r\n}, 0)\r\nsetTimeout(function () {\r\nislock = false;\r\n}, 500)\r\n}\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/pre>\n<p>\u9700\u8981\u81ea\u5df1\u628a&lt;a href=&#8221;#&#8221; rel=&#8221;external nofollow&#8221; rel=&#8221;external nofollow&#8221; rel=&#8221;external nofollow&#8221; rel=&#8221;external nofollow&#8221; rel=&#8221;external nofollow&#8221; &gt;<br \/>\n&lt;img src=&#8221;.\/images\/1.jpg&#8221; alt=&#8221;&#8221;&gt;&lt;\/a&gt;\u4e2d\u7684.\/images\/1.jpg\uff0c\u6362\u6210\u81ea\u5df1\u7684\u56fe\u7247\u8def\u5f84\u3002<\/p>\n<p>\u9700\u8981\u81ea\u5df1\u4fee\u6539\u4e0b\u4ee3\u7801<\/p>\n<pre>&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"UTF-8\"&gt;\r\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n&lt;title&gt;\u7b80\u5355\u8f6e\u64ad\u56fe&lt;\/title&gt;\r\n&lt;style&gt;\r\n*{\r\nmargin: 0;\r\npadding: 0;\r\n}\r\n.wp{\r\nwidth: 250px;\r\nheight: 400px;\r\nmargin: 40px auto 0;\r\nposition: relative;\r\noverflow: hidden;\r\n}\r\n#list{\r\ndisplay: flex;\r\nwidth: 1000px;\r\ntransform: translateX(0);\r\n\/* \u6dfb\u52a0\u8fc7\u6e21\u52a8\u753b *\/\r\ntransition: all 1s;\r\n}\r\n.wp div img{\r\nwidth: 250px;\r\nheight: 400px;\r\n}\r\n#box {\r\nheight: 40px;\r\nwidth: 100%;\r\nposition: absolute;\r\nbackground: rgba(0, 0, 0, 0.5);\r\nleft: 0;\r\nbottom: 0;\r\ndisplay: flex;\r\njustify-content: center;\r\nalign-items: center;\r\n}\r\n#box span {\r\nwidth: 10px;\r\nheight: 10px;\r\nbackground: #fff;\r\nborder-radius: 50%;\r\nmargin: 0 5px;\r\ncursor: pointer;\r\n}\r\n#box span:hover{\r\nbackground: pink;\r\nbox-shadow: 0 0 0 2px #ccc;\r\n}\r\n#r{\r\nwidth: 20px;\r\nheight: 20px;\r\nposition: absolute;\r\ntop: 170px;\r\nright: 0;\r\nbackground: url(.\/images\/\u53f3\u7bad\u5934.png)no-repeat 0 0\/100% 100%;\r\n}\r\n#l{\r\nwidth: 20px;\r\nheight: 20px;\r\nposition: absolute;\r\ntop: 170px;\r\nleft: 0;\r\nbackground: url(.\/images\/\u5de6\u7bad\u5934\\ \\(1\\).png)no-repeat 0 0\/100% 100%;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;!-- \u5916\u5c42\u7684div\uff0c\u5305\u542b\u56fe\u7247\u5217\u8868 --&gt;\r\n&lt;div class=\"wp\"&gt;\r\n&lt;div id=\"list\"&gt;\r\n&lt;img src=\".\/images\/\u5fae\u4fe1\u56fe\u7247\u7f16\u8f91_20221118164531.jpg\" alt=\"\"&gt;\r\n&lt;img src=\".\/images\/\u5fae\u4fe1\u56fe\u7247\u7f16\u8f91_20221118170018.jpg\" alt=\"\"&gt;\r\n&lt;img src=\".\/images\/\u5fae\u4fe1\u56fe\u7247\u7f16\u8f91_20221118170050.jpg\" alt=\"\"&gt;\r\n&lt;img src=\".\/images\/\u5fae\u4fe1\u56fe\u7247\u7f16\u8f91_20221118170113.jpg\" alt=\"\"&gt;\r\n&lt;\/div&gt;\r\n&lt;!-- \u5206\u9875\u5668 --&gt;\r\n&lt;div id=\"box\"&gt;\r\n&lt;span&gt;&lt;\/span&gt;\r\n&lt;span&gt;&lt;\/span&gt;\r\n&lt;span&gt;&lt;\/span&gt;\r\n&lt;span&gt;&lt;\/span&gt;\r\n&lt;\/div&gt;\r\n&lt;div id=\"r\"&gt;&lt;\/div&gt;\r\n&lt;div id=\"l\"&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n&lt;script&gt;\r\n\/\/ \u83b7\u53d6\u9700\u8981\u70b9\u51fb\u7684\u5206\u9875\u5668\r\nlet box = document.getElementById('box');\r\nlet spanBox = box.getElementsByTagName('span');\r\n\/\/ \u83b7\u53d6\u5217\u8868\u5143\u7d20\r\nlet list = document.getElementById('list');\r\n\r\n\/\/ \u70b9\u51fb\u5206\u9875\u5668\r\nspanBox[0].onclick = function () {\r\nlist.style.transform='translateX(0px)'\r\n};\r\nspanBox[1].onclick = function () {\r\nlist.style.transform='translateX(-250px)'\r\nconsole.log('\u70b9\u51fb\u4e86\u7b2c\u4e8c\u4e2a\u56fe\u7247');\r\n};\r\nspanBox[2].onclick = function () {\r\nlist.style.transform='translateX(-500px)'\r\n};\r\nspanBox[3].onclick = function () {\r\nlist.style.transform='translateX(-750px)'\r\n};\r\n\r\nlet n = 0;\r\nlet r = document.getElementById('r');\r\nlet l = document.getElementById('l');\r\nr.onclick = function (){\r\nn&lt;3? n++ :n;\r\nconsole.log(n);\r\nlist.style.transform='translateX(-'+n*250+'px)'\r\n};\r\nl.onclick = function (){\r\nn&gt;0? n-- :n=0;\r\nconsole.log(n);\r\nlist.style.transform='translateX(-'+n*250+'px)'\r\n};\r\n&lt;\/script&gt;<\/pre>\n<p>\u4e0a\u9762\u4ee3\u7801\u4e0d\u7406\u89e3\uff0c\u4e5f\u53ef\u4ee5\u7528ai \u76f4\u63a5\u751f\u6210\u4ee3\u7801\uff0c\u81ea\u5df1\u5728\u4fee\u6539\u4e0b\u3002\uff08\u5982\u4e0b\u56fe\u662f \u8c46\u5305ai \u751f\u6210\u4ee3\u7801\uff0c\u53ef\u4ee5\u5728\u8be6\u7ec6\u95ee\u95ee\uff0c\u751f\u6210\u66f4\u597d\u7684\u3002\uff09<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone  wp-image-3424\" src=\"http:\/\/www.yuan95.cn\/wp-content\/uploads\/2024\/06\/fd318fb8824db30.jpg\" alt=\"\u8c46\u5305ai \u751f\u6210\u4ee3\u7801\" width=\"610\" height=\"390\" srcset=\"https:\/\/www.yuan95.cn\/wp-content\/uploads\/2024\/06\/fd318fb8824db30.jpg 996w, https:\/\/www.yuan95.cn\/wp-content\/uploads\/2024\/06\/fd318fb8824db30-300x192.jpg 300w, https:\/\/www.yuan95.cn\/wp-content\/uploads\/2024\/06\/fd318fb8824db30-768x491.jpg 768w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><\/p>\n<p>\u5982\u8fd8\u4e0d\u77e5\u9053\uff0c\u63d0\u4f9b\u6709\u507f\u4ed8\u8d39\u6307\u5bfc\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u5c31\u662f\u6f14\u793a\u6548\u679c\u3002 &nbsp; \u4e0b\u9762\u662f\u4ee3\u7801\u3002\u9700\u8981\u81ea\u5df1\u628a&lt;img src=&#8221;2.png&#8221; style=&#8221;background-color: bisque;&#8221;&gt; \u4ee3\u7801\u4e2d\u76842.png\uff0c&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"topic":[],"class_list":["post-3239","post","type-post","status-publish","format-standard","hentry","category-jianzhan"],"_links":{"self":[{"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=\/wp\/v2\/posts\/3239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3239"}],"version-history":[{"count":11,"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=\/wp\/v2\/posts\/3239\/revisions"}],"predecessor-version":[{"id":3425,"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=\/wp\/v2\/posts\/3239\/revisions\/3425"}],"wp:attachment":[{"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3239"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yuan95.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=3239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}