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?

http://jsfiddle.net/vuj6t/2/

<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; } } 

http://jsfiddle.net/vuj6t/3/


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -