<div> <style type="text/css"> .tab_wrap { position: relative; height: 1.8rem; } .tab_content { position: absolute; top: 0; left: 0; } .tab_content, .tab_content a { display: block; width: 7.41rem; margin-left: 0.03rem; height: 2.2rem; overflow: hidden; } .tab_content.tab_img { z-index: 1; margin-top: 0.25rem; } .tab_content.tab_bg { z-index: 2; } .tab_content.tab_a { z-index: 3; } </style> <div class="tab_wrap"> <div class="tab_content tab_img" id="tabe"> <!-- 第一张图片链接 --> <img src="https://gfs9.gomein.net.cn/wireless/T1.x_kBbxT1RCvBVdK_1085_200.jpg" id="img"> </div> <div class="tab_content tab_a" id="tabe"> <!-- 第一张图片对应的跳转链接 --> <a href="https://game.m.gome.com.cn/happyChick.html?gameCollectId=145001&gameItem=happyChick&gameId=145007" id="a"></a> </div> <div class="tab_content tab_bg"> <!-- 框图片的链接 --> <img src="https://gfs8.gomein.net.cn/wireless/T1KcCABKLv1RCvBVdK_1125_276.png" alt=""> </div> </div> <script> /* img_src 里面存放banner图片链接,每个图之间用英文逗号隔开。 img_a 里面存放图片跳转链接,顺序要与图片对上,每个图之间用英文逗号隔开。 */ var img_src = [ "https://gfs8.gomein.net.cn/wireless/T14g_kBK_v1RCvBzVdK_1219_200.png", "https://gfs9.gomein.net.cn/wireless/T1.x_kBbxT1RCvBVdK_1085_200.jpg", "https://gfs6.gomein.net.cn/wireless/T1yKKABs_T1RCvBVdK_1085_200.jpg", "https://gfs6.gomein.net.cn/wireless/T1KsLkBC_v1RCvBVdK_1125_200.jpg"]; var img_a = [ "https://prom.m.gome.com.cn/html/prodhtml/topics/202111/3/channeleMbFrXfIkmt.html", "https://game.m.gome.com.cn/happyChick.html?gameCollectId=145001&gameItem=happyChick&gameId=145007", "https://prom.m.gome.com.cn/gcms/MobsaleymeflHt8vg7.html", "https://prom.m.gome.com.cn/html/prodhtml/topics/202203/1/channel3dXyO66u9xm.html"]; var index = 0; function qiehuan() { document.getElementById("img").src = img_src[index]; document.getElementById("a").href = img_a[index]; index++; /* index>x; x的值为banner图片数量-1 */ if (index > 3) { index = 0; } } setInterval('qiehuan()', 5000); </script></div>