博客侧边栏添加tab3栏图片自动切换,图片可自行更换,效果吗自己喜欢就好。首先在侧边栏添加html小工具并填入下面的代码:
<div id="lurenfencom" class="lurenfencom">
<div class="menu">
<ul>
<li id="one1">冬天</li>
<li id="one2">已经</li>
<li id="one3">来了</li>
</ul>
</div>
<div class="menudiv">
<div id="con_one_1"><img src="https://cdn.zxki.cn/tc/2023/11/23/c08a1c238b410.jpeg" alt="冬日美景" /></div>
<div id="con_one_2" style="display: none;"><img src="https://cdn.zxki.cn/tc/2023/11/23/c08a1c238b410.jpeg" alt="冬日美景" /></div>
<div id="con_one_3" style="display: none;"><img src="https://cdn.zxki.cn/tc/2023/11/23/c08a1c238b410.jpeg" alt="冬日美景" /></div>
</div>
</div>
<div style="text-align: center; clear: both;"></div>
<script type="text/javascript">
function setTab(name,cursel){
cursel_0=cursel;
for(var i=1; i<=links_len; i++){ var menu = document.getElementById(name+i); var menudiv = document.getElementById("con_"+name+"_"+i); if(i==cursel){ menu.className="off"; menudiv.style.display="block"; } else{ menu.className=""; menudiv.style.display="none"; } } } function Next(){ cursel_0++; if (cursel_0>links_len)cursel_0=1
setTab(name_0,cursel_0);
}
var name_0='one';
var cursel_0=1;
var ScrollTime=1000;//循环周期(毫秒)
var links_len,iIntervalId;
onload=function(){
var links = document.getElementById("lurenfencom").getElementsByTagName('li')
links_len=links.length;
for(var i=0; i<links_len; i++){
links[i].onmouseover=function(){
clearInterval(iIntervalId);
this.onmouseout=function(){
iIntervalId = setInterval(Next,ScrollTime);;
}
}
}
document.getElementById("con_"+name_0+"_"+links_len).parentNode.onmouseover=function(){
clearInterval(iIntervalId);
this.onmouseout=function(){
iIntervalId = setInterval(Next,ScrollTime);;
}
}
setTab(name_0,cursel_0);
iIntervalId = setInterval(Next,ScrollTime);
}
</script>
大家可以根据自己的需求更改里面的内容然后在主题自定义CSS样式里面填入下面的css代码:
/*tab三榜*/
.menu li{float:left;width:33.33%;text-align:center;line-height:28px;height:28px;cursor:pointer;font-size:14px;overflow:hidden;margin-bottom:5px;}
.menu li.off{background:var(--main-bg-color);color:var(--key-color);font-weight:bold;font-size: 18px;}
.menudiv{background:var(--main-bg-color);}
感谢您的来访,获取更多精彩文章请收藏本站。
© 版权声明
THE END
暂无评论内容