解决方法
when the button is inside the div that needs to hide.
简答:不,当按钮位于元素内部时,您无法实现此目的.谢谢Joseph Marikle
但是,当按钮位于div之外时,您可以实现此目的.
#hide { display: none; } label { cursor: pointer; text-decoration: underline; } #hide:checked ~ #randomDiv { display: none; }
<input type="checkBox" id="hide" /> <div id="randomDiv"> This is a div <label for="hide">Hide div</label> </div>