The problem doesn't lie with the border box property, but rather with the width of your inner elements. The main issue stems from how you're positioning the elements. It's best to refrain from specifying top, right, etc. positions in pixels. Instead, utilize margins and consider reducing the width of your elements if necessary. Here are some changes that I've implemented:
header {
display: flex;
/* width: 90%; */
height: 4.8vh;
/* margin: auto; */
/* align-items: center; */
margin: 10px;
position: relative;
}
.profile-pic {
/* position: relative; */
/* left: 92%; */
border-radius: 50%;
height: 4.8vh;
}
.logo img {
height: 92px;
width: 272px;
margin:auto;
/* text-align: center; */
}
.logo {
padding-top: 47px;
/* position: relative; */
text-align: center;
/* left: 500px; */
top: 25px;
}
.language {
font-size: small;
position: relative;
/* left: 590px; */
text-align: center;
}
.ending {
display: flex;
list-style: none;
position: relative;
/* right: 880px; */
flex: 2;
padding-left : 50px;
}
.btm-navlinks {
margin-right: 30px;
color: rgba(0, 0, 0, 0.54);
}
Introduce a div wrapper around the header elements to shift them to the right:
<header>
<div class="header-wrap">
<nav>
<ul class="nav-links">
<li><a class="nav-link1" href="#">Gmail</a></li>
<li><a class="nav-link2" href="#">Bilder</a></li>
</ul>
</nav>
<div class="burger-menu">
<a href="#"
><img
class="burger-menulink"
src="./Pictures/Skärmavbild 2020-07-07 kl. 17.33.43.png"
alt="burger-menu"
/></a>
</div>
<div class="profile-pic">
<a href="#"
><img
class="profile-pic"
src="https://lh3.googleusercontent.com/ogw/ADGmqu_I3j_aWjRLGl97SmvJwotO5yAsUOC4AmXnL7MK=s192-c-mo"
alt="profile picture"
/></a>
</div>
</div>
</header>
.header-wrap{
position: absolute;
right:2%;
display: flex;
align-items: center;
}
Avoid using external images within input text; consider the background property instead
.form-control-search {
display: flex;
border: 1px solid #dfe1e5;
box-shadow: none;
border-radius: 24px;
z-index: 3;
height: 44px;
margin: 0 auto;
width: 50%;
outline: none;
margin-top: 40px;
font-size: 17px;
background-image: url(./Pictures/mglass.svg), url(./Pictures/voice_icon.svg);
background-position: left, right;
background-repeat: no-repeat,no-repeat;
padding:0 4% ;
}
.form-control-search:hover {
box-shadow: 0 0 11px #dfe1e5;
}
Get rid of the image divs and wrap a button around your buttons instead:
<form
action="https://www.google.com/search"
class="search-form"
method="get"
name="serachform"
target="_blank"
>
<input name="sitesearch" type="hidden" />
<input
type="text"
autocomplete="on"
class="form-control-search"
name="q"
required
/>
<div class="button-wrap">
<button class="button" type="submit">Search on Google</button>
<button class="button" type="submit">I'm Feeling Lucky</button>
</div>
</form>
.button-wrap{
margin: 10px auto;
width: fit-content;
}
Remember to save the two SVG images in the Pictures folder as mglass.svg and voice_icon.svg
With these changes, you should be all set to go...
PS: Only use position:relative
when absolutely necessary