html - Css sibling (~) selector doesn't work with checked property -


why doesn't css below work me? can advise me please.

#slide1:checked ~ #inner { margin-left: 0;} #slide2:checked ~ #inner { margin-left: -800px;} #slide3:checked ~ #inner { margin-left: -1600px;} 

the css below work. don't know go here.

#slide1:checked ~ #broadcontrol label:nth-child(1), #slide2:checked ~ #broadcontrol label:nth-child(2), #slide3:checked ~ #broadcontrol label:nth-child(3){     background: #333;     border-color: #333; !important; } 

html:

<div id="broadcast">     <div id="overflow">         <div id="inner">              <article>                 <div class="info"></div>                 <div id="pic1"></div>                 <!--img src=""-->             </article>             <article>                 <div class="info"></div>                 <div id="pic2"></div>                 <!--img src=""-->             </article>             <article>                 <div class="info"></div>                 <div id="pic3"></div>                 <!--img src=""-->             </article>          </div>     </div> </div>  <!-- broadcast controls --> <input checked type="radio" name="slider" id="slide1"> <input type="radio" name="slider" id="slide2"> <input type="radio" name="slider" id="slide3"> <div id="broadcontrol">     <label for="slide1"></label>     <label for="slide2"></label>     <label for="slide3"></label> </div> 

i'm trying make slide transition pure css understand more in css.

but i've been stuck here 3 days now.

i have no idea why doesn't work.

if have ideas, please suggest them me.

thanks in advance.

#slide1:checked ~ #broadcontrol label:nth-child(1) 

the ~ operator works on elements after element. in case, #slide1 searches #broadcontrol label elements after #slide1, cannot search before it.

example fiddle:
http://jsfiddle.net/9vxyj/

you see in fiddle moved #broadcast portion after broadcast controls.

the other issue ~ sibling selector, means can find elements on same level. can work around this, since #broadcast on same level #slide1 etc., can bury #inner, so:

#slide1:checked ~ #broadcast > #overflow > #inner { margin-left: 0;} #slide2:checked ~ #broadcast > #overflow > #inner { margin-left: -800px;} #slide3:checked ~ #broadcast > #overflow > #inner { margin-left: -1600px;} 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -