Fixed positioned div within a relative parent div

后端 未结 9 1878
春和景丽
春和景丽 2020-12-05 17:40

I am currently building a responsive website and need a menu to be fixed, thus not scrolling when the rest of the site scrolls. the issue is that it is a fluid layout and i

9条回答
  •  春和景丽
    2020-12-05 18:20

    This question came first on Google although an old one so I'm posting the working answer I found, which can be of use to someone else.

    This requires 3 divs including the fixed div.

    HTML

    CSS

    .wrapper { position:relative; width:1280px; }
        .parent { position:absolute; }
            .child { position:fixed; width:960px; }
    

提交回复
热议问题