There's a header div and it's width should be the same with the screen(not the window).I tried to set it's width to be 100%, but When the browser wi开发者_如何学运维ndow became narrower the div became narrower too, so when I scroll to the right, the header div isn't long enough to the right.
How to make the div width not change with the window?You need to set the width of the div to a fixed width. So try
width:980px;
This will prevent the div from collapsing when the browser is resized unlike setting the width with a percentage. You may need to change the width to suite your needs or preference.
Further Reading: http://coding.smashingmagazine.com/2009/06/02/fixed-vs-fluid-vs-elastic-layout-whats-the-right-one-for-you/
You either set it to concrete value like
width:1000px;
or with percents
width: 100%;
you can calculate width of the window on load and set it with javascript though.
You put width:1000px;
in main container div. Then inner div's you put percentage or pixels.
精彩评论