【发布时间】:2021-01-25 13:08:53
【问题描述】:
我整天都在努力寻找一个简单的纯css / html代码,只是为了在单击按钮时使div消失。我更喜欢 CSS,但如果不可能,我会改用 JS 解决方案。
很多关于溢出的解决方案,但大多数使用 js。请查看下面的代码并在下面添加示例或建议。感谢您的帮助,Stewy
body {
background-color: #6B6B6B;
font-family: Arial;
color: grey;
font-size: 12px;
margin: 0px;
}
/*............... bgcover ...............*/
.bgcover {
position: fixed;
top: 50px;
left: 50px;
width: 200px;
height: 200px;
background-color: rgba(0, 0, 0, .4);
}
.call {
position: fixed;
top: 100px;
left: 100px;
}
/*........ crossfade on buttons ........*/
.hover,.nohover{
transition:.3s;
position:absolute;
}
.nohover{
opacity:0;
}
a:hover .hover{
opacity:0;
}
a:hover .nohover{
opacity:1;
}
<div class="bgcover" align="center">
<p>Button turns off this bg cover div.</p>
</div>
<div class="call">
<a href="bgcoveroff.htm">
<img src="http://wizzfree.com/pix/call2.png" width="100" class="nohover">
<img src="http://wizzfree.com/pix/call.png" width="100" class="hover"></a>
</div>
【问题讨论】:
标签: html css button onclick divide