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?
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.
Edit this works with the following styles:
html,body {
padding:0;
margin:0;
height:100%;
min-height:100%;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With