javascript - How to make content next to a fixed-position menu not overlap in smaller resolutions -


i'm trying figure out how make if user has browser window that's under 1024px (the site has no horizontal-scroll @ 1024px+), if scroll right see more of main content, not overlapped/messy'd left fixed-position menu.

i've made js fiddle recreates basic problem facing: http://jsfiddle.net/ye7zz/1/

css

#wrap {     width:100%;     background-image:url('../images/imagine/bg_image44.png');     background-attachment:fixed; }   #top {  }  #left {     position:fixed;     border:1px solid red;     background:pink;     width:250px; } #positioner {     margin-left:250px;     width:auto; } #content {     border:1px solid green;     width:700px;     margin:auto;         background:grey;  } 

html

    <div id="wrap">     <div id="top"></div>     <div id="left">menu item~~~~~<br /><br /><br />menu item~~~~~<br /><br /><br />menu item~~~~~<br /><br /><br />menu item~~~~~<br /><br /><br />menu item~~~~~<br /><br /><br />menu item~~~~~<br /><br /><br /></div>     <div id="positioner">         <div id="content">asdf content should lower-resolution browser friendly , not overlapped menu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />              asdf content should lower-resolution browser friendly , not overlapped menu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />             asdf content should lower-resolution browser friendly , not overlapped menu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />             asdf content should lower-resolution browser friendly , not overlapped menu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />         </div>     </div> </div> 

i have attempted solve issue 3 separate times on course of past 6 weeks , have not been able find fix, appreciated much.

thank time.

edit-- ideal solution horizontal scroll-bar appears content portion, can scroll through content itself, without having to: 1) overlap left menu; or 2) cut off amount of content viewable; or 3) reduce size of left menu

solved: thank @gaby aka g. petrioli

i used javascript solution:

$(document).ready(function(){ var lastleft = -1,     menu = $('.left_, .top_');  $(window).on('scroll resize', function(){     var left = $(window).scrollleft();     if (left >= 0 && left!==lastleft){         lastleft = left;         menu.css('left',-left+'px');     } }); 

});

and changed css outlined, , on live version, had change positioning top menu elements fixed absolute. thank everyone!

not sure of specific needs remove width:700px .content rule , element shrink viewport does..

demo at http://jsfiddle.net/ye7zz/2/


if on other hand need maintain layout, , want fixed apply vertical scrolling, have use jquery (not possible pure css)

var lastleft = -1,     menu = $('#left'); $(window).on('scroll resize', function(){     var left = $(window).scrollleft();     if (left >= 0 && left!==lastleft){         lastleft = left;         menu.css('left',-left+'px');     } }); 

demo at http://jsfiddle.net/ye7zz/3/


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -