nav,
nav ul {
list-style: none;
margin: 0px;
border: 0px solid black;
display: inline;
background-color: #d3d3d3;
padding: 4px;
text-transform: uppercase;
text-align: center;
}
nav li {
list-style: none;
margin: 0px;
padding: border: 1px solid black;
display: inline;
background-color: #d3d3d3;
text-transform: uppercase;
text-align: center;
}
nav a {
text-decoration: none;
display: inline-block;
color: black;
}
nav a:hover {
margin: 0px;
padding: 4px;
border: 1px solid black;
display: inline;
background-color: #cc0000;
text-transform: uppercase;
text-align: center;
text-decoration: none;
}
#currentlink {
margin: 0px;
padding: 0px;
border: 1px solid black;
display: inline;
background-color: #cc0000;
padding: 4px;
text-transform: uppercase;
text-align: center;
text-decoration: none;
}
<nav>
<ul>
<a href="home.html">Home</a>
<a id="currentlink" href="news.html">News</a>
<a href="bilder.html">Bilder</a>
<a href="videos.html">Videos</a>
</ul>
</nav>
答案 0 :(得分:1)
nav a:hover
有一个填充和边框设置,但它们不在nav a
上。这基本上是将这些添加到元素的宽度。
移动:
padding: 4px;
border: 1px solid black;
到nav a
,这将是固定的。
您还合并了nav li
样式