Reputation: 1
I'm trying to develop a horizontal web page, with fixed height and variable width.
In order to get it, I need a row of floating <div>
s to expand the <body>
width.
|------------- body --------------| /* variable width */
|-div-| |-div-| |-div-| |-div-| /* fixed width */
The following code doesn't seem to work:
body{
height: 40px;
}
div{
width: 2000px;
height: 20px;
background: red;
margin: 10px;
float: left;
}
Is is possible to do so without using javascript?
Upvotes: 0
Views: 1551
Reputation: 51201
Block elements expand to the full width of their parent-element's width. To make them respect their childrens with you can either declare:
display: inline-block;
or
position:absolute;
on your body-element.
EDIT: after you clarified your question - simply add the white-space
declaration to your body:
white-space:nowrap;
Upvotes: 2