Without either padding, height or width, the content disappears after a time of 5000 as it's meant to be. But once I include any of the following properties, the background remains after setTimeOut(), only the text disappears. How can I fix this? You can run my code to see what I mean.
const msg = "Welcome";
document.getElementById("alarmmsg").innerHTML = msg;
setTimeout(function(){
document.getElementById("alarmmsg").innerHTML = '';
}, 4000);
.Javascript-Message-disappears-1{
width: 100px;
height: auto;
background-color: crimson;
text-align: center;
position: absolute;
top: calc(100vh - 70px);
padding: 20px;
box-sizing: border-box;
}
<body>
<div class="Javascript-Message-disappears-1" id="alarmmsg"></div>
</body>