The header was vertically aligned before I tried including the user's profile picture, but I can't seem to get it now. After trial and error, this is what I have so far:
HTML/PHP:
<ul id="right-side">
<li>
<a href="">
<img src="<?php echo $user['profile_pic'];?>" id="profilepic">
<?php echo $user['user_name'];?>
</a>
</li>
</ul>
CSS:
nav {
position: fixed;
right: 0px;
top: 0px;
z-index: 1000;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
}
#right-side {
display: inline;
float: right;
text-align: right;
}
#right-side a {
vertical-align: middle;
}
#profilepic {
height:50px;
width 50px;
border-radius:50px;
}
You can try this code.
nav {
position: fixed;
right: 0px;
top: 0px;
z-index: 1000;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
padding: 0 10px;
}
#right-side {
display: inline;
float: right;
text-align: right;
}
#right-side li {
list-style-type: none;
}
#right-side a {
display: flex;
align-items: center;
}
#right-side a img {
margin-right: 10px;
}
#profilepic {
height:50px;
width 50px;
border-radius:50px;
}
<nav>
<ul id="right-side">
<li>
<a href="">
<img src="https://cdn.onlinewebfonts.com/svg/img_235843.png" id="profilepic">
John
</a>
</li>
</ul>
</nav>
</div>
I assume you mean you want the username and picture to both be aligned vertically, side by side? If so, check out this fiddle.
CSS
#right-side {
display: inline;
float: right;
text-align: right;
}
#profile-pic {
left: 0;
float: left;
width: 50px;
}
#profile-name {
margin-left: 55px;
top: 0;
}
#profilepic {
height: 50px;
width: 50px;
border-radius: 50px;
}
HTML
<ul id="right-side">
<div id="profile-pic">
<img src="https://i.stack.imgur.com/34AD2.jpg" id="profilepic">
</div>
<div id="profile-name">
User Name
</div>
</ul>