THE WORLD'S LARGEST WEB DEVELOPER SITE
×

HOW TO

HowTo Home

Menus

Icon Bar Menu Icon Accordion Tabs Vertical Tabs Tab Headers Full Page Tabs Top Navigation Responsive Topnav Search Bar Fixed Sidebar Side Navigation Fullscreen Navigation Off-Canvas Menu Hover Sidenav Buttons Horizontal Scroll Menu Vertical Menu Bottom Navigation Responsive Bottom Nav Bottom Border Nav Links Fixed Menu Slide Down Bar on Scroll Sticky Navbar Hover Dropdowns Click Dropdowns Dropdown in Navbar Mega Menu Pagination Breadcrumbs Button Group Vertical Button Group

Images

Slideshow Slideshow Gallery Modal Images Lightbox Responsive Image Grid Image Grid Tab Gallery Image Overlay Image Effects Image Text Image Text Blocks Transparent Image Text Full Page Image Hero Image Rounded Images Thumbnails Meet the Team Sticky Image Flip an Image Shake an Image Portfolio Gallery Portfolio with Filtering Image Zoom Image Magnifier Glass

Buttons

Alert Buttons Animated Buttons Social Media Buttons Loading Buttons Next/prev Buttons Round Buttons Scroll To Top Button

Forms

Login Form Signup Form Contact Form Newsletter Responsive Form Clear Input Field Copy Text to Clipboard Animated Search Custom Checkbox/Radio Check Checkbox Toggle Switch Password Validation Toggle Password Visibility Multiple Step Form

Filters

Filter List Filter Table Filter Elements Sort List Sort Table

More

Fullscreen Video Modal Boxes Timeline Scroll Indicator Progress Bars Skill Bar Range Sliders Tooltips Popups Calendar Zebra Striped Table Responsive Tables HTML Includes To Do List Loaders Star Rating User Rating Overlay Effect Contact Chips Cards Profile Card Alerts Notes Labels Circles Coupon Fixed Footer Equal Height Clearfix Snackbar Scroll Drawing Sticky Header Pricing Table Parallax Aspect Ratio Build a Web Site Toggle Like/Dislike Toggle Hide/Show Toggle Class Add Class Remove Class Active Class Arrows Shapes Browser Window Custom Scrollbar Device Look Placeholder Color Vertical Line Animate Icons Countdown Timer Typewriter Coming Soon Page Center Website Chat Messages Testimonials Draggable HTML Element Syntax Highlighter JS Animations Contact Section

Grid

2 Column Layout 3 Column Layout 4 Column Layout Expanding Grid List Grid View Mixed Column Layout Blog Layout

Google

Google Maps Google Translate Google Charts Google Fonts

Converters

Convert Weight Convert Temperature Convert Length Convert Speed

How TO - Fixed Menu


Learn how to create a "fixed" menu with CSS.


Try it Yourself »


How To Create a Fixed Top Menu

Step 1) Add HTML:

Example

<div class="navbar">
  <a href="#home">Home</a>
  <a href="#news">News</a>
  <a href="#contact">Contact</a>
</div>

<div class="main">
  <p>Some text some text some text some text..</p>
</div>

Step 2) Add CSS:

To create a fixed top menu, use position:fixed and top:0. Note that the fixed menu will overlay your other content. To fix this, add a margin-top (to the content) that is equal or larger than the height of your menu.

Example

/* The navigation bar */
.navbar {
    overflow: hidden;
    background-color: #333;
    position: fixed; /* Set the navbar to fixed position */
    top: 0; /* Position the navbar at the top of the page */
    width: 100%; /* Full width */
}

/* Links inside the navbar */
.navbar a {
    float: left;
    display: block;
    color: #f2f2f2;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

/* Main content */
.main {
    margin-top: 30px; /* Add a top margin to avoid content overlay */
}
Try it Yourself »

How To Create a Fixed Bottom Menu

To create a fixed bottom menu, use position:fixed and bottom:0:

Example

/* The navigation bar */
.navbar {
    position: fixed; /* Set the navbar to fixed position */
    bottom: 0; /* Position the navbar at the bottom of the page */
    width: 100%; /* Full width */
}

/* Main content */
.main {
    margin-bottom: 30px; /* Add a bottom margin to avoid content overlay */
}
Try it Yourself »

Tip: Go to our CSS Navbar Tutorial to learn more about navigation bars.