I am making a sticky navbar which has circlular avatars, each with an alphabet A-Z, a total of 26 circles. When it is on full screen, it works fine. But when I switch to smaller screen view, the scroll doesnt let me traverse initial values.
As visible, the scroll doesnt scroll past 'J' to the left and thus I can't see values A-I
Here is the code.
let box = document.getElementById('box')
let circles = ""
for(let i=65;i<91;i++)
circles+=`<a href=#><div class="circle" onclick="print('${String.fromCharCode(i)}')"><span class="inner">${String.fromCharCode(i)}</span></div></a>`
box.innerHTML = circles
function print(value) {
console.log(value)
}
html{font-family: 'Comfortaa', cursive;}
a{text-decoration: none;outline: none;}
#box{
padding: 20px;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
overflow-x: auto;
position: sticky;
position: -webkit-sticky;
top: 0;
}
.circle{
min-height: 50px;
min-width: 50px;
border-radius: 50px;
background-color: #f9dbbd;
margin-left: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.inner{
color: #450920;
font-weight: 700;
}
<html>
<body>
<div style="height: 1300px;background-color: red;"></div>
<div id="box"></div>
<div style="height: 1300px;background-color: red;"></div>
<div style="height: 1300px;background-color: green;"></div>
</body>
</html>
Thanks for your time!