gpt4 book ai didi

html - 将 CSS 菜单从选项卡悬停转换为选项卡单击

转载 作者:太空宇宙 更新时间:2023-11-03 18:29:19 24 4
gpt4 key购买 nike

我需要你的帮助,

如何修改下面的代码,而不是将鼠标悬停在选项卡上来切换它们,而不是让用户可以点击选项卡来切换它们?

这是一个 fiddle :

http://jsfiddle.net/QA5Zp/

CSS:

body{
font : 12px/1.5 Helvetica, Arial serif;
}
.clearboth{
clear:both;
}


#csstabs li{ padding:2px;}

#csstabs{ position:relative; width:500px; height:290px; }
#csstabs h3{ padding:5px; height:30px; text-align:center; cursor:hand; display:block; font-size:16px; font-weight:bold; margin:0;
border-top:1px solid #000;
border-left:1px solid #000;
border-right:1px solid #000;
}


.tabcontent{
padding:10px 0 0 40px;
width:100%;
background:#fff;
border:1px solid #000;
position:absolute;
left:0;
top:40px;
height:230px;
display:block;
margin:0;
}


#tab1 .tabcontent{
z-index:2;
background:#fff;
}
#tab1 h3{
z-index:3;
width:150px;
position:absolute;
left:0;
top:0;
cursor:hand;
background:#fff;
}


#tab2 .tabcontent{
z-index:1;
opacity:0;
}
#tab2 h3{
width:150px;
position:absolute;
left:180px;
top:0;
cursor:hand;
}

#csstabs:hover h3, #tabs:focus h3, #tabs:active h3{
background:none;
z-index:0;
}

#csstabs:hover .tabcontent, #tabs:focus .tabcontent, #tabs:active .tabcontent{
z-index:0;
opacity:0;
-webkit-transition : opacity .75s ease-in;
}

#tab1:hover h3,#tab1:focus h3,#tab1:active h3{z-index:4;background:#fff;}
#tab1:hover .tabcontent,#tab1:focus .tabcontent,#tab1:active .tabcontent{ z-index:3; background:#fff; opacity:1; -webkit-transition : opacity 2s ease-in;}

#tab2:hover h3,#tab2:focus h3,#tab2:active h3{z-index:4;background:#fff;}
#tab2:hover .tabcontent,#tab2:focus .tabcontent,#tab2:active .tabcontent{ z-index:3; background:#fff; opacity:1; -webkit-transition : opacity 2s ease-in;}

最佳答案

只要您愿意花一些时间确定正确的目标并添加更多标签,就可以使用 CSS 点击事件。参见 CSS Click Events

关于html - 将 CSS 菜单从选项卡悬停转换为选项卡单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20184235/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com