PDA

View Full Version : CSS Layout problem



jp504
07 Nov 2010, 12:02 AM
Is it possible that have a fixed-width div span across the entire window. Just like a fluid layout would be 100%. If possible could anyone provide sample code.

Wickham
07 Nov 2010, 03:00 AM
Is it possible that have a fixed-width div span across the entire window. Just like a fluid layout would be 100%. If possible could anyone provide sample code.

No.

If the width is 100% it will adjust to the width of a viewer's window.

If fixed width it will stay fixed and create a horizontal scrollbar if necessary. You can add margin: auto to the div or page wrapper which, together with the fixed width, will center the width in larger windows and you can show a body background over the whole window.

If you code the div with left: 0; right: 0; and position: absolute or position: fixed; the div will stretch to the full width provided the div has no width or is width: 100%.