This is my CSS for the header:
#header {
font-size: 3rem;
width: 100%;
height: 4.5em;
display: flex;
align-items: center;
padding-left: 1em;
}
As you can see, it is set to 100% width. On the website however, it shows up like this, with a horizontal scroll bar at the bottom:
For some reason, the header extends past the html tag. overflow: hidden
does nothing. 100vw doesn't change anything either. My other divs' width is also 100%. Not getting any errors in the console. Here is my html:
<body onload="setBgColors()"> <!-- function that sets certain background colors using Colorthief is called on load -->
<div id='header'>
<div class='flag-container'><img src="images/tree.png" alt="Flag" id="flag"></div>
<h1 id="title">Fussajle</h1>
<button id='edit-button'>Edit</button>
</div>
<ul class="tabs">
<li data-tab-target="#overview">
<div class="tab-button" id='default-button'>
Overview
</div>
</li>
<li data-tab-target="#learn">
<div class="tab-button">
Learn
</div>
</li>
<li data-tab-target="#more">
<div class="tab-button">
More
</div>
</li>
</ul>
...
</body>
The rest of my CSS:
.flag-container {
width: calc(2.75em + 10px);
height: calc(2.75em + 10px);
background-color: #fcfcfc;
border-radius: 50%;
}
#flag {
width: 2.75em;
height: 2.75em;
object-fit: cover;
border-radius: 50%;
border: 5px solid #ffffff;
}
#title {
margin-left: 1em;
}
#edit-button {
font-size: 1.5rem;
width: 3em;
height: 2em;
border-radius: 5px;
margin-left: calc(100vw - 33em); /* for edit button to be always on the right side of the screen relative to the vw*/
}
/* tabs */
.tabs {
width: 100%;
height: 3.5rem;
display: flex;
}
.tabs li {
width: calc(100% / 3);
height: 100%;
}
.tabs div {
font-size: 1.5rem;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
Help would be appreciated.