How can I make a menubar fixed on the top while scrolling

前端 未结 4 1423
攒了一身酷
攒了一身酷 2020-12-09 19:49

I\'d like to make a menubar, which is fixed on the top of the page while scrolling. Something like the top menu in Facebook.

Also, I want a div holding the logo flo

4条回答
  •  一向
    一向 (楼主)
    2020-12-09 20:15

    The postition:absolute; tag positions the element relative to it's immediate parent. I noticed that even in the examples, there isn't room for scrolling, and when i tried it out, it didn't work. Therefore, to pull off the facebook floating menu, the position:fixed; tag should be used instead. It displaces/keeps the element at the given/specified location, and the rest of the page can scroll smoothly - even with the responsive ones.

    Please see CSS postion attribute documentation when you can :)

提交回复
热议问题