I am trying to get the first li element to start at the same place as the ul element.
I want this :
It is working when put a margin-left:-3% in the first li element but this does not work when the screen is resized.
Without the margin, It looks like this :
And this is my code :
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.nav {
background-color: black;
height: 10%;
width: 100%;
}
body {
height: 100%;
}
html {
height: 100%;
}
li {
list-style-type: none;
padding: 1.25%;
height: 100%;
}
li:hover {
background-color: magenta;
}
li:first-child {
background-color: green;
}
a {
text-decoration: none;
color: white;
}
li {
float: left;
}
li:nth-child(3) {
background-color: blueviolet;
}
li:last-child {
float: right;
}
</style>
</head>
<body>
<ul class="nav">
<li><a href="www.google.ca">Home</a></li>
<li><a href="www.google.ca">News</a></li>
<li><a href="www.google.ca">Contact</a></li>
<li><a href="www.google.ca">About</a></li>
</ul>
</body>
</html>