The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › CSS › target element doesn't respond
I’m trying to do the left_warrper invisible, and after the user click on the “click me” button, then the left_warrper changes to visible, but the :target element doesn’t work for some reason
Here’s the code example: https://codepen.io/xwp003x/pen/OxyXgX
You’re having issues because of the HTML structure.
Your selector :target ~ .left_wrapper requires that the left-wrapper is a sibling of the targeted element … and it isn’t.
:target ~ .left_wrapper
left-wrapper
Your target is inside the nav and so it can’t be selected by that CSS selector.
nav
You need to change the structure
https://codepen.io/Paulie-D/pen/OxyRJj