Hide Div With Opacity Transition
Hide div with CSS and disable mouse events
HTML
<div id="minhaId">
<h1>Hello, World!</h1>
<h2>Howdy?</h2>
</div>
<button onclick="ocultar()">Hide</button>
<button onclick="mostrar()">Show</button>
CSS
div {
display: block;
opacity: 1;
transition: display .5s linear;
}
div.hide {
display: none;
opacity: 0;
}
#minhaId {
margin: 0 auto;
width: 80%;
box-shadow: 0 0 10px grey;
padding: 20px;
box-sizing: border-box;
border-radius: 5px;
font-family: sans-serif;
text-align: center;
}
button {
width: 100%;
padding: 5px;
margin: 10px auto;
width: 80%;
display: block;
}
JavaScript
function ocultar() {
var element = document.getElementById("minhaId");
element.classList.add("hide");
}
function mostrar() {
var element = document.getElementById("minhaId");
element.classList.remove("hide");
}