How to create: Pill-shaped navigation
- Previous Page Sticky Social Bar
- Next Page Responsive Page Header
Learn how to use CSS to create a pill-shaped navigation menu.
Pill-shaped navigation
Create a pill-shaped navigation
Step 1 - Add HTML:
<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>
Step 2 - Add CSS:
/* Set link styles within 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 link color on hover */ .pill-nav a:hover { background-color: #ddd; color: black; } /* Add color for active/current link */ .pill-nav a.active { background-color: dodgerblue; color: white; }
Vertical pill-shaped navigation
Add display: block to the links, and they will be displayed vertically instead of horizontally:
Related Pages
Tutorial:CSS Navigation Bar
Tutorial:How to Create Top Navigation Bar
- Previous Page Sticky Social Bar
- Next Page Responsive Page Header