I have a page with a button; and when I click on it I want to have a transition which display a block and remove the button.
Here is my code:
HTML
<body>
<p class="launch-game">Launch Game</p>
<div class="wrapper clearfix">
<form>
<p id="question" class="question"></p>
<div class="block-answers">
<button id="answer-0" type="submit" class="answer"></button>
<button id="answer-1" type="submit" class="answer"></button>
<button id="answer-2" type="submit" class="answer"></button>
</div>
<p id="result" class="result"></p>
</form>
</div>
<script src="script.js"></script>
</body>
CSS
.wrapper {
transform: translate(-50%, -50%);
background-color: #fff;
box-shadow: 0px 10px 50px rgba(0, 0, 0, 0.3);
overflow: hidden;
display: none;
transition: opacity 2s;
opacity: 0;
}
.launch-game {
text-align: center;
font-family: Lato;
font-size: 20px;
text-transform: uppercase;
cursor: pointer;
font-weight: 300;
}
Here is my EvenListener when I click on the button
document.querySelector('.launch-game').addEventListener('click',
function() {
document.querySelector('.launch-game').style.display = 'none';
document.querySelector('.wrapper').style.display = 'block';
document.querySelector('.wrapper').style.opacity = '1';
});