Hello Everyone,
Is there a way to stretch my navigation bar so that the links are evenly spaced out across the browser window instead of being clustered together? I want it to be responsive rather than fixed in size.
This is my HTML code:
<div class="navbar-wrapper">
<img src="./images/R_medum.jpg" class="nav-image" alt="" />
<div class="navbar-links">
<ul>
<li><a href="#" title="There is no place like it">127.0.0.1</a></li>
<li><a href="https://google.com">About</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#"> YouTube </a></li>
</ul>
</div>
</div>
Here is my CSS code:
.navbar-wrapper {
width:100%;
display: inline;
float: left;
}
.navbar-wrapper img {
float: left;
}
#navbar {
margin: 0;
padding: .3em 0 .3em 0;
display: inline;
float: left;
}
.navbar-links ul {
list-style: none;
margin: 50px;
padding: 0;
display: table;
float: left;
text-align: justify;
width: calc(10% -115px);
}
.navbar-links li {
vertical-align: center;
padding: 0;
display: table-cell;
text-align: center;
float: left;
white-space: nowrap;
width: calc(calc(100 - 115px) / 4);
}
.navbar-links ul a {
margin: 0;
padding: .3em .4em .3em .4em;
text-decoration: none;
font-weight: bold;
font-size: 1.5em;
background-color: black;
color: orange;
}
.navbar-links ul a:visited {
margin: 0;
padding: .3em .4em .3em .4em;
text-decoration: none;
font-weight: bold;
font-style: italic;
font-size: 1.5em;
color: green;
}
.navbar-links ul a:active {
margin: 0;
padding: .3em .4em .3em .4em;
text-decoration: none;
font-weight: bold;
font-size: medium;
color: white;
}
.navbar-links ul a:hover {
margin: 0;
padding: .3em .4em .3em .4em;
text-decoration: none;
font-weight: bold;
font-size: 1.8em;
color: #f6f0cc;
background-color: #227755;
}
What I have attempted:
I've tried multiple methods but haven't found a solution yet. Adjusting the padding settings helped, but it wasn't consistent across different screen sizes. I also experimented with setting the navbar-links as a table, the ul element as a table-row, and the li elements as table-cells, but this didn't work for me and I'm unsure why.
If you have any suggestions on how I can achieve this layout, please share!
JSFIDDLE Link:
https://jsfiddle.net/uoxgLvbL/