How do I toggle <p> with a html link using only css -
i been working while trying have link show , hide paragraph below it.
i need accomplish using css. paragraph must hidden on load , show once link clicked , hide again when link clicked again.
how can accomplish this?
<a …………………>my link</a> <p>sed ut perspiciatis unde omnis iste natus</p>
i appreciate help..
short answer: need javascript.
after all, that's intended for: user interaction, among other cool things. css on other hand oriented towards presentation, interaction features limited (for example, responds hover action not click action in way expect it).
the idea comes mind using checkbox control click "states" , in css display based on status.
html:
<label><input type="checkbox">my link <p>sed ut perspiciatis unde omnis iste natus</p> </label>
css:
input[type="checkbox"] {display: none;} input[type="checkbox"] + p {display:none; margin-left:1em;} input[type="checkbox"]:checked + p {display:block;}
however, solution not best cross-browser wise, go "javascript" ;)
Comments
Post a Comment