我在buttons.html中有按钮的标签,在images.html中有图片。 当我从buttons.html打开按钮时,我想从images.html隐藏1张图片。 我怎么能这样做? 这是buttons.html的按钮
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch"> <span class="onoffswitch-inner"></span> <span class="onoffswitch-switch"></span> </label>
<img src="image.jpg" />
</div>
CSS:
#myonoffswitch ~ img
{
display:none;
}
#myonoffswitch:checked ~ img
{
display:block;
}
答案 0 :(得分:-2)
更改
#myonoffswitch ~ img
{
display:none;
}
#myonoffswitch:checked ~ img
{
display:block;
}
到
.myonoffswitch ~ img
{
display:none;
}
.myonoffswitch:checked ~ img
{
display:block;
}
从我那里开始。