html - close a div when a checkbox clicked with pure css -


i trying close div when checkbox clicked css not jquery or javascript seems not working properly. how can adjust it?

    div[id^="div-"] {       	display: block;      }      div[id^="div-"]:target {  	    display: none;      }
    <a href="#div-1"><input type="checkbox" checked></a>      <div id="div-1">                     here content.       </div>

how can link <a> click , checkbox?

i think way pure css have checkbox direct sibling div:

#div-1 {display:none}  #checkbox:checked + #div-1 {display:block;}
<input id="checkbox" type="checkbox" checked>  <div id="div-1">                 here content.   </div>


Comments