我在buttons.html中有按钮标签,在images.html中有图像标签。
当我从button.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;
}
最佳答案
更改
#myonoffswitch ~ img
{
display:none;
}
#myonoffswitch:checked ~ img
{
display:block;
}
至
.myonoffswitch ~ img
{
display:none;
}
.myonoffswitch:checked ~ img
{
display:block;
}
从这里开始。