有没有办法在纯CSS中执行以下操作:如果我的rds-trigger-button
的课程活跃,我希望tab
div可见,否则将被隐藏。如果其他同级拥有类别,则在兄弟上运行CSS
HTML:
<div>
<div class="rds-trigger-button"><span class="rds-carrot">▼</span> Learn More</div>
<div class="tab">
Cardigan organic four loko, Etsy art party Godard jean shorts. Chillwave next level letterpress lumbersexual wolf jean shorts, church-key ugh vegan typewriter PBR four loko. Occupy whatever chillwave, pug tote bag organic migas High Life hoodie flannel Schlitz small batch distillery DIY.
</div>
</div>
CSS:
.rds-trigger-button{
border: 1px blue solid;
width:100px;
padding:12px;
position:relative;
}
.rds-trigger-button.active{
border-bottom:1px white solid;
z-index:9999;
}
.rds-trigger-button.active + .tabs{
display:block !important;
}
.rds-carrot{
font-size:10px;
color:#ccc;
padding-right:8px;
}
.tab{
display:none;
position:absolute;
margin-top:-1px;
width:356px;
background-color:#fff;
min-height:50px;
padding:24px;
border: 1px #2E51A1 solid;
}
http://jsfiddle.net/0sqoaxxs/2/
你已经回答了你的问题;使用相邻的兄弟选择器'A + B'。 – 2015-02-24 00:00:34