html - css how to prevent content from drifting underneath fixed position areas? -
i've created html template have sidebar set position: fixed;
when minimize browser less width page set to, main content drifts underneath sidebar when user viewing sidescrolls.
is there fix set entire container sidebar , main content single fixed block?
<body> <div id="container"> <section id="sidebar"> <nav> <ul> <li><a href="/"></a></li> <li><a href="/"></a></li> <li><a href="/"></a></li> </ul> </nav> </section> <section id="stream"> <article> </article> <article> </article> <article> </article> </section> </div> </body> body { height: 100%; overflow: auto; margin: 0; padding: 0; position: relative; } #container { margin: 0 auto; padding: 0; position: relative; width: 700px; } #sidebar { display: block; float: left; overflow: hidden; position: fixed; width: 200px; } #stream { float: right; margin: 0 0 0 210px; padding: 0; width: 490px; }
you absolutely position sidebar on narrow screens using simple media query like
@media (max-width: 690px) { #sidebar { position:absolute; } }
Comments
Post a Comment