I have this problem when I try to add a logo to my navbar. When I put the logo before the other navbar items the logo is way too big and when I try to resize it still looks out of place. I would like to have to logo in line with the other items or have the other navbar items to be centered in line with the logo. I think using flexbox would be a lot simpler and make this process easier, but I would like to avoid using flexbox here for this navbar.
nav {
background: rgb(255, 255, 255);
padding: 10px;
box-shadow: rgba(120, 126, 133, 0.2) 0px 8px 24px;
padding: 2em;
padding-bottom: 0.6em;
padding-top: 0.6em;
}
nav ul {
list-style: none;
text-align: center;
margin-top: 0px;
padding-left: 0px;
margin-bottom: 0px;
}
nav ul li {
display: inline-block;
}
nav ul li a {
display: block;
padding: 15px;
padding-top: 10px;
padding-bottom: 10px;
text-decoration: none;
color: rgb(0, 0, 0);
font-weight: 800;
text-transform: uppercase;
margin: 0 10px;
}
nav ul li a,
nav ul li a:after,
nav ul li a:before {
transition: all .5s;
}
nav ul li a:hover {
color: #555;
}
nav.stroke ul li a,
nav.fill ul li a {
position: relative;
}
nav.stroke ul li a:after,
nav.fill ul li a:after {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 0%;
content: '.';
color: transparent;
background: rgb(255, 255, 255);
height: 1px;
}
nav.fill ul li a {
transition: all 2s;
}
nav.fill ul li a:after {
text-align: left;
content: '.';
margin: 0;
opacity: 0;
}
nav.fill ul li a:hover {
color: rgb(0, 0, 0);
z-index: 1;
}
nav.fill ul li a:hover:after {
z-index: -10;
animation: fill 0.6s forwards;
-webkit-animation: fill 0.6s forwards;
-moz-animation: fill 0.6s forwards;
opacity: 1;
}
.fill img {
width: 80px;
image-rendering: -moz-crisp-edges;
/* Firefox */
image-rendering: -o-crisp-edges;
/* Opera */
image-rendering: -webkit-optimize-contrast;
/* Webkit (non-standard naming) */
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor;
text-align: center;
}
<nav class="fill">
<ul>
<li><img src="https://i.imgur.com/bblqj5b.png" alt="SCP"></li>
<li><a href="index.html">Home</a></li>
<li><a href="wwd.html" target="blank_">What we do</a></li>
<li><a href="#">Goal 1</a></li>
<li><a href="#">Goal 2</a></li>
<li><a href="lildicky.html">Earth by Lil Dicky</a></li>
</ul>
</nav>
A very quick patch without flexbox is to add the declaration: vertical-align: middle;
to your nav ul li { }
rule
nav {
background: rgb(255, 255, 255);
padding: 10px;
box-shadow: rgba(120, 126, 133, 0.2) 0px 8px 24px;
padding: 2em;
padding-bottom: 0.6em;
padding-top: 0.6em;
}
nav ul {
list-style: none;
text-align: center;
margin-top: 0px;
padding-left: 0px;
margin-bottom: 0px;
}
nav ul li {
display: inline-block;
vertical-align: middle;
}
nav ul li a {
display: block;
padding: 15px;
padding-top: 10px;
padding-bottom: 10px;
text-decoration: none;
color: rgb(0, 0, 0);
font-weight: 800;
text-transform: uppercase;
margin: 0 10px;
}
nav ul li a,
nav ul li a:after,
nav ul li a:before {
transition: all .5s;
}
nav ul li a:hover {
color: #555;
}
nav.stroke ul li a,
nav.fill ul li a {
position: relative;
}
nav.stroke ul li a:after,
nav.fill ul li a:after {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 0%;
content: '.';
color: transparent;
background: rgb(255, 255, 255);
height: 1px;
}
nav.fill ul li a {
transition: all 2s;
}
nav.fill ul li a:after {
text-align: left;
content: '.';
margin: 0;
opacity: 0;
}
nav.fill ul li a:hover {
color: rgb(0, 0, 0);
z-index: 1;
}
nav.fill ul li a:hover:after {
z-index: -10;
animation: fill 0.6s forwards;
-webkit-animation: fill 0.6s forwards;
-moz-animation: fill 0.6s forwards;
opacity: 1;
}
.fill img {
width: 80px;
image-rendering: -moz-crisp-edges;
/* Firefox */
image-rendering: -o-crisp-edges;
/* Opera */
image-rendering: -webkit-optimize-contrast;
/* Webkit (non-standard naming) */
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor;
text-align: center;
}
<nav class="fill">
<ul>
<li><img src="https://i.imgur.com/bblqj5b.png" alt="SCP"></li>
<li><a href="index.html">Home</a></li>
<li><a href="wwd.html" target="blank_">What we do</a></li>
<li><a href="#">Goal 1</a></li>
<li><a href="#">Goal 2</a></li>
<li><a href="lildicky.html">Earth by Lil Dicky</a></li>
</ul>
</nav>