How to make this navigation bar floating on top while scrolling?

前端 未结 3 723
無奈伤痛
無奈伤痛 2021-01-28 04:20

The whole navigation bar along with its JavaScript settings can be found here

http://jsfiddle.net/DyJzg/3/

right now it stays at the top of the page, but i am wo

相关标签:
3条回答
  • 2021-01-28 04:46

    I think you need to use position:fixed

    nav {
    position:fixed;
    top:0;
    width:100%;
    }
    

    here is modified jsfiddle

    0 讨论(0)
  • 2021-01-28 04:46

    Just off the top of my head, the following should do it..

    .nav{
       display:block;
       position:absolute;
       top:0;
       left:0;
       right:0;
       width:100%;
    }
    
    0 讨论(0)
  • 2021-01-28 04:50

    if your element is 'nav' or your element class is '.nav' use this piece of css code:

    nav, .nav{
    position:fixed;
    top:0;
    width:your_custom_with;
    height: your_custom_height
    }
    

    note: check this article of css positioning for more details: http://www.w3schools.com/css/css_positioning.asp

    0 讨论(0)
提交回复
热议问题