Reputation: 3669
How to mark up the page without javascript?
Both HTML elements (div1, div2) must to have fixed size.
Upvotes: 2
Views: 386
Reputation: 26022
You have to work with the CSS attributes
position
,
top
,
bottom
,
left
,
right
and
height
.
E.g.
<div style="position:absolute; left:0; right:0; top:0; bottom:0">
<div style="position:absolute; left:0; right:0; top:0; height:42px; background:green">div1</div>
<div style="position:absolute; left:0; right:0; bottom:0; top:42px; background:red">div2</div>
</div>
position:absolute
lets you determine the layout in pixels and percent (roughly speaking).left:0; right:0
make it full-width.top:0
aligns a div to the upper edge.bottom:0
aligns a div to the lower edge.height:42px
and top:42px
define the tiled layout.<div style="position:absolute; left:0; right:0; top:0; bottom:0">
<div style="position:absolute; top:0; bottom:0; left:0; width:42px; background:green">d i v 1</div>
<div style="position:absolute; top:0; bottom:0; right:0; left:42px; background:red">d i v 2</div>
</div>
<div style="position:absolute; left:0; right:0; top:0; bottom:0">
<div style="position:absolute; top:0; height:80px; left:0; width:42px; background:green">d i v 1</div>
<div style="position:absolute; top:0; height:80px; right:0; left:42px; background:red">d i v 2</div>
<div style="position:absolute; top:80px; bottom:0; left:0; width:42px; background:red">d i v 3</div>
<div style="position:absolute; top:80px; bottom:0; right:0; left:42px; background:green">d i v 4</div>
</div>
Notice how top
+height
resp. left
+width
work together.
You could have more tiles as well by adding the previous height to the next top.
With overflow
you can define what should happen if there is too much content. overflow:auto
adds a scrollbar to the div if needed. overflow:hidden
would crop it.
Upvotes: 3
Reputation: 3246
While I have not tried a layout like the one you have mentioned, you can try the technique mentioned here (negative margins.)
http://www.alistapart.com/articles/negativemargins
Upvotes: 0