I am having trouble splitting a screen into 4 divs with width and height of 50%. It's no problem to get the 50% width and float them around, but how can I get each of them to have a height of 50% of the screen?
A:
I presume you've used to set your width; well the same thing can be used for your height.
For example:
<html>
<head>
</head>
<body>
<div style="background-color:red; width:50%; height:50%; float:left">
</div>
<div style="background-color:blue; width:50%; height:50%; float:right">
</div>
<div style="background-color:green; width:50%; height:50%; float:left">
</div>
<div style="background-color:orange; width:50%; height:50%; float:right">
</div>
</body>
</html>
If you run this, you will have 4 equal parts in your screen, with top-left being red, top-right being blue, bottom-left being green, and bottom-right being orange.
Vincent Couture
2010-10-12 22:14:42
Dont't get the reason, why the elemts stretch now to a height of 50%.But they do.
Sven Klouem
2010-10-12 22:39:48