Reputation:
Im having such a weird offset when i try too center a h1 and a horizontal align list ...
The list has a slightly offset too the right, but why? How can i center both perfectly?
* {
box-sizing: border-box;
}
body {
background-color: black;
}
header h1 {
position: relative;
text-align: center;
font-size: 5.5em;
font-weight: bold;
font-family: Arial;
letter-spacing: 11px;
color: white;
}
nav {
font-family: Verdana;
font-size: small;
text-align: center;
word-spacing: 15px;
list-style-type: none;
}
li {
display: inline;
}
li a {
text-decoration: none;
display: inline-block;
color: white;
}
<body>
<header>
<h1>Header</h1>
</header>
<nav>
<ul>
<li><a href="#">Leben</a></li>
<li><a href="#">Karriere</a></li>
<li><a href="#">Alben</a></li>
<li><a href="#">Filme</a></li>
<li><a href="#">Auszeichnungen</a></li>
</ul>
</nav>
</body>
Thanks for the help, very appreciate it
Upvotes: 0
Views: 39
Reputation: 56754
Just remove the margin/padding from the ul
:
nav ul {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
body {
background-color: black;
}
header h1 {
position: relative;
text-align: center;
font-size: 5.5em;
font-weight: bold;
font-family: Arial;
letter-spacing: 11px;
color: white;
}
nav {
font-family: Verdana;
font-size: small;
text-align: center;
word-spacing: 15px;
list-style-type: none;
}
nav ul {
margin: 0; padding: 0;
}
li {
display: inline;
}
li a {
text-decoration: none;
display: inline-block;
color: white;
}
<body>
<header>
<h1>Header</h1>
</header>
<nav>
<ul>
<li><a href="#">Leben</a></li>
<li><a href="#">Karriere</a></li>
<li><a href="#">Alben</a></li>
<li><a href="#">Filme</a></li>
<li><a href="#">Auszeichnungen</a></li>
</ul>
</nav>
</body>
Upvotes: 2