I have a navigation that stretches across the whole page by using flex-growth and flex-basis properties.
HTML:
<!DOCTYPE html>
<html lang="en">
<body>
<div id="main_navigator">
<div id="main_navigator_upper">
<a id="main_navigator_logo" src="/"></a>
<ul id="main_navigator_r1">
<li>
<a class="main_nav_btn">BTN 1</a>
</li>
<li>
<a class="main_nav_btn">BTN 2</a>
</li>
<li>
<a class="main_nav_btn">BTN 3</a>
</li>
<li>
<a class="main_nav_btn">BTN 4</a>
</li>
<li>
<div id="main_navigator_s1"></div>
</li>
<li>
<ul id="main_navigator_regbox">
<li>
<p id="regbox_signin">sign in</p>
</li>
<li id="main_navigator_l1">
<div id="main_navigator_regbox_s1"></div>
</li>
<li>
<a id="regbox_signup" href="sign_up">sign up</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</body>
</html>
In order to make these elements stretch through the whole screen by their width, I can use this code:
#main_navigator_r1 {
display: flex;
flex-direction: row;
align-items: center;
flex-grow: 1;
flex-shrink: 1;
padding: 0;
padding-right: 5%;
text-align: center;
margin-top: 0px;
height: 98px;
list-style-type: none;
}
#main_navigator_r1 li {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0;
}
which finally gives me this result.
But unfortunately, this doesn't look very pleasant - golden spacer's parent's width is too long, thus I solved this problem by decreasing flex-growth specifically for this list item, I gave list item its unique id main_navigator_l1.
#main_navigator_r1 li {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0;
}
#main_navigator_l1 {
flex-grow: 0.1 !important;
}
Problem:
For some reason, as window gets smaller, spacer gets closer to the element on the right side and this affects the symmetry between elements. You can see this by scaling this page.
How can I decrease the size of one specific element of flexbox without affecting symmetry (#main_navigator_l1 in this case)?
Thank you!