Reputation: 124
Everything was going well until I decided that I wanted my fixed navigation menu to be full width. I can't seem to find a way to get the ul to align in the centre, whilst having its parent container as 100%. It was centred until I added the 100% property to its parent
JS Fiddle :https://jsfiddle.net/u504xgey/
nav {
position: fixed;
z-index: 1;
background-color: #ff3300;
width: 100%;
}
nav a {
color: #ffffff;
text-decoration: none;
transition: color 2s;
}
nav a:hover {
color: yellow;
}
ul {
display: block;
margin: auto;
list-style: none;
}
li {
display: inline-block;
color: #ffffff;
margin: 10px 40px;
}
<header>
<nav>
<ul>
<li>
<a href="#landing">
<h3>Home</h3>
</a>
</li>
<li>
<a href="#about">
<h3>About</h3>
</a>
</li>
<li>
<a href="#projects">
<h3>Projects</h3>
</a>
</li>
<li>
<a href="#contact">
<h3>Contact</h3>
</a>
</li>
</ul>
</nav>
</header>
Upvotes: 0
Views: 37
Reputation: 13
Or centering the UL text :
ul{
margin: auto;
list-style: none;
text-align: center;
}
li{
display: inline-block;
color: #ffffff;
margin: 10px 40px;
}
Upvotes: 0
Reputation: 1428
Just add margin: 0
property to your body selector.
body {
background-color: #ffffff;
font-family: "objektiv-mk1", sans-serif;
color: #fffff;
margin: 0;
}
Upvotes: 1