如何使div在点击时消失?

问题描述

我整天都在尝试寻找一个简单的简短纯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,.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>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)