Learn how to create a pill navigation menu with CSS.
<div class="pill-nav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
/* Style the links inside the pill navigation menu */
.pill-nav a {
display: inline-block;
color: black;
text-align: center;
padding: 14px;
text-decoration: none;
font-size: 17px;
border-radius: 5px;
}
/* Change the color of links on mouse-over */
.pill-nav a:hover {
background-color: #ddd;
color: black;
}
/* Add a color to the active/current link */
.pill-nav a.active {
background-color: dodgerblue;
color: white;
}
Try it Yourself »
Add display: block
to the links, and they will appear vertically instead of horizontally:
Tip: See also How To Create a Top Navigation Menu.
Tip: Go to our CSS Navbar Tutorial to learn more about navigation bars.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!