I'm not sure why is this happening. When I remove:
.nav-username {
display: flex;
align-items: center;
}
the elements align horizontally, however, the image and text stop being aligned vertically because I've removed the display: flex
and align-items: center
.
$('.dropdown').on('click', function() {
$('.navigation-ul li:not(:first-child)').toggleClass('active');
});
*,
*:after,
*:before {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
text-decoration: none;
color: white;
}
a {
color: #f1f1f1;
}
html {
font-size: 16px;
}
body {
background-color: #fafafa;
font-family: 'Roboto', sans-serif;
height: 100%;
width: 100%;
}
.navigation {
background-color: #171717;
}
.navigation-ul {
display: flex;
align-items: center;
}
.navigation-ul>li:not(.dropdown) {
padding: 10px 15px 10px 15px;
font-weight: 500;
text-align: center;
font-size: 1em;
color: white;
background-color: #151719;
list-style-type: none;
}
.navigation-ul li:nth-last-child(2) {
margin-left: auto;
}
.nav-username {
display: flex;
align-items: center;
}
.profile-picture {
display: inline-block;
border-radius: 50px;
height: 30px;
width: 30px;
margin-right: 10px;
}
@media all and (min-width: 0px) and (max-width: 1200px) {
.navigation-ul {
flex-wrap: wrap;
}
.navigation-ul>li {
flex: 1 1 100%;
}
}
@media screen and (max-width: 1200px) {
.navigation-ul li:first-child {
display: block;
}
.navigation-ul li {
display: none;
}
.navigation-ul li.active {
display: block;
}
.navigation-ul .dropdown {
display: block;
cursor: pointer;
}
.home-container {
columns: 2;
}
.dropdown {
padding: 7px 0 7px 0;
text-align: center;
}
.specific-image-flexbox {
flex-direction: column;
}
}
@media screen and (max-width: 600px) {
.home-container {
columns: 1;
}
.category-container-element {
width: 100%;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class='navigation'>
<div class="wrapper">
<ul class="navigation-ul">
<li class='dropdown'>Dropdown</li>
<li><a href="">Images</a></li>
<li><a href="">Categories</a></li>
<li><a href="">Upload</a></li>
<li>
<a class='nav-username' href=''>
<img class='profile-picture' src=''> Username
</a>
</li>
<li><a href="">Logout</a></li>
</ul>
</div>
</nav>