Learn how to create bottom bordered (underline) navigation links with CSS.
<div class="topnav">
<a href="#home" class="active">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
</div>
/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
border-bottom: 3px solid transparent;
}
.topnav a:hover {
border-bottom: 3px solid red;
}
.topnav a.active {
border-bottom: 3px solid red;
}
Try it Yourself »
Tip: To create mobile-friendly, responsive navigation bars, read our How To - Responsive Top Navigation tutorial.
Tip: Go to our CSS Navbar Tutorial to learn more about navigation bars.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!