/* Add a lightgray right border to all list items, except the last */
ul li {
float: left;
border-right: 1px solid #bbbbbb;
}
ul
li:last-child {
border-right: none;
}
Fixed Navigation Bar
You can make the navigation bar to stay fixed at the top or at the bottom of a page, by using the position property along with top or bottom:
Fixed Top
ul {
position: fixed;
top: 0;
width: 100%;
}
Fixed Bottom
ul {
position: fixed;
bottom: 0;
width: 100%;
}
Note: Fixed position might not work properly on mobile devices.
Sticky Navigation Bar
Add position: sticky; to
to create a sticky navbar.
An element with position: sticky; toggles between a relative and fixed position, depending on the scroll position.
A sticky element is positioned relative until a certain scroll position is reached - then it "sticks" in that place (like position: fixed).
Example
ul {
position: sticky;
top: 0;
}
Note: You must specify at least one of the top, right, bottom or left properties, for sticky positioning to work.
Dropdown Menu in Navigation Bar
Here we create a dropdown menu for one of the menu links:
Quick answers about learning Horizontal Navbar in CSS.
This free note from CodingNow 2.0 explains Horizontal Navbar in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on CodingNow 2.0, including Horizontal Navbar, is 100% free with no signup required.
With focused practice, most students grasp Horizontal Navbar in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.