Despite its simplicity, I have been struggling to position one of the items on the right side. Currently, I have multiple items and I am trying to get the 'Logout' button to stick to the right.
body {
margin: 0;
background: #222;
font-family: 'Work Sans', sans-serif;
font-weight: 400;
}
.container {
width: 100%;
margin: 0 auto;
}
header {
background: #55d6aa;
}
header::after {
content: '';
display: table;
clear: both;
}
nav {
float: left;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 70px;
padding-top: 25px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 14px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
.logout {
margin-left: -90%;
}
<header>
<div class="container">
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">Chat</a></li>
<li><a href="#">Profile</a></li>
<div class="logout">
<li><a href="#">Logout</a></li>
</div>
</ul>
</nav>
</div>
</header>
The workaround solution I attempted involved creating a div named 'logout' and adding float: right;
to .logout
in the main.css file. Unfortunately, this did not produce the desired result and only made matters worse.