我试图根据当前检查的单选按钮显示/隐藏超链接。这是有效的,直到我将radiobuttons包裹在<ul><li>
元素内。
CSS
.site {
opacity: 0;
height: 0px;
-moz-transition: opacity .5s ease-in-out, height .5s ease-in-out,background .5s ease-in-out;
-webkit-transition: opacity .5s ease-in-out, height .5s ease-in-out,background .5s ease-in-out;
transition: opacity .5s ease-in-out, height .5s ease-in-out,background .5s ease-in-out;
}
input[id=rbSites]:checked ~.site {
opacity: 1;
height: 15px;
}
HTML
<input type="radio" id="rbSites" name="types">
<label for="supportCase">Sites</label>
<input type="radio" id="rbOther" name="types">
<label for="other">Other</label>
<div class="cell site">Link to</div>
<a class="site">SiteX</a>
<a class="site">SiteY</a>
<a class="moblie">AppX</a>
一旦radiobuttons被包裹在<ul><li>
个元素内,上面就会停止工作,如下所示:
<ul>
<li>
<input type="radio" id="rbSites" name="types">
<label for="supportCase">Sites</label>
<input type="radio" id="rbOther" name="types">
<label for="other">Other</label>
</li>
<ul>