2016-04-09 17 views
0

Sadece CSS ile tıklandığında div içeriğini göstermek/gizlemek istiyorum. Aşağıdaki kodla bunu yapabilirim ama yapmam gereken şey, CSS 'hedef' seçicisini satır içi içine yerleştirmektir. Herhangi bir yardım için teşekkür ederiz. ThxCSS 'hedef' seçici satır içi HTML işaretlemede nasıl kullanılır?

<style> 
.openDiv {display: none;} 
.openDiv:target {display: block;} 
</style> 
<ul> 
<li><a href="#Expando1">The Tick</a> 
<ul class="openDiv" id="Expando1"> 
<li>Has superhuman strength and mass;</li> 
<li>Is nigh-invulnerable; </li> 
<li>Has powers that increase as the situation becomes more dramatic;</li> 
<li>Does not seem to require oxygen;</li> 
<li>Cannot keep his balance if his antennae are removed.</li> 
</ul>  
</li> 
</ul> 

cevap

0

Sen ... seçiciler inline ... sadece stilleri olamaz olamaz. Yeniden düşünmeniz gerekecek. Belki de "onay kutusu kesmek"?

input[type="checkbox"] { 
 
    position: absolute; 
 
    display: none; 
 
} 
 
input[type="checkbox"] ~ ul { 
 
    display: none; 
 
} 
 
input[type="checkbox"]:checked ~ ul { 
 
    display: block; 
 
}
<ul> 
 
    <li> 
 
    <input type="checkbox" class="expando" id="expando" /> 
 
    <label for="expando">The Tick</label> 
 
    <ul class="openDiv" id="openDiv1"> 
 
     <li>Has superhuman strength and mass;</li> 
 
     <li>Is nigh-invulnerable;</li> 
 
     <li>Has powers that increase as the situation becomes more dramatic;</li> 
 
     <li>Does not seem to require oxygen;</li> 
 
     <li>Cannot keep his balance if his antennae are removed.</li> 
 
    </ul> 
 
    </li> 
 
</ul>

İlgili konular