Wordpress how to make sticky navigation menu / make the menu stick to the top all the time?


Tags: css,wordpress,menu,navigation,sticky

Problem :

I am using Wordpress default theme Twenty Twelve, my website is: http://ninarakovec.com.

I would like to make my existing navigation menu stick to the top all the time whilst scrolling, for example like website called wpsites (can't post the link because of stackoverflow's link limit).

You can view the theme's CSS here: http://pastebin.com/muXyT6AY

How would I go on about doing this, I have no idea what to do, I currently have made it so you can click on the navigation bar and it takes you to that respective section on the page, but the menu doesn't stick to the top so it isn't what I wanted. Please help!



Solution :

This should work:

.site-header {
    position: fixed;
    top: 0;
    width: 100%;
    left: 0;
    background-color: lightblue;
    z-index: 1000;
}
.main-navigation ul.nav-menu {
    border: 0;
}

    CSS Howto..

    how to fix the css padding in this situation?

    CSS - How to remove white
    margins

    how can you have layers see through each other on a web page

    How to add a 3rd level to my CSS drop down menu?

    How to make an item background visible on overflow?

    How to add the img-responsive class in javascript

    Thymeleaf: how to use conditionals to add/remove dynamically a CSS class

    How can I use JQ to pick out a parent whose child is hr.strong?

    How to add a value in the y-axis at the bottom of a bar chart-css

    How to select not first tr and not last td

    How to align a flash movie to center with “overflow: hidden”?

    How to keep nav menu highlighted after click using js in sidebar

    How to Find CSS Selector

    How can I create HTML/CSS responsive tile?

    How to change the color of header?

    How can I prevent overflow from a fieldset?

    SMACSS and BEM: How to position Module inside of a Module?

    How to change the background color of an input field when text is entered?

    How to write a:hover in inline CSS?

    How to display a button over a picture only when hovering it?

    How to Load Resources (Css, js files) in Laravel 4 (Optimization)

    How to remove the arrows in a scroll bar through CSS

    How to import css dynamically with js?

    Understanding float and how and when to float an element in CSS3?

    How do I get these hover effects but with diamonds instead of circles

    how to affect an element's width by one child element but not others using CSS

    Greasemonkey: How to do something when style=“display: none;” changes?

    How do I align text and an image vertically inside a DIV?

    How can I take pseudo:after { content: “Value”; } value dynamically in this snippet?

    How to create a div filling the vertical available space without overlapping the containing div?