My goal in the code is to achieve a simple layout. The white divs should always be centered horizontally with a fixed width of 80vw and relative height. I want to hide the vertical scrollbar and have the horizontal one set to auto. Unfortunately, I am facing an issue where the horizontal scrollbar appears unnecessarily. When I try to hide it, the entire content disappears and I am unable to identify the problem.
var array = ['cat', 'dog', 'lion', 'tiger', 'snake']
for (var i = 0; i < 50; i++) {
var random = Math.floor(Math.random() * (array.length));
var n = array[random];
var container = document.getElementById("container");
container.innerHTML += '<div class="box">' + n + '</div>';
}
*{
outline:none;
transition:1s;
}
::-webkit-scrollbar:horizontal {
display: none;
}
html,body {
position:absolute;
left:0;
top:0;
margin:0;
padding:0;
width:100vw;
}
#container {
position:absolute;
top:0;
left:0;
height:auto;
width:100vw;
background-color: black;
}
.box {
height: auto;
width:80vw;
margin-left:10vw;
margin-top:10vh;
text-align:center;
vertical-align:middle;
font-size:calc(2vh + 2vw);
background-color: white;
}
<html>
<head>
</head>
<body>
<div id="container"></div>
</body>
</html>