开发者

Split screen into 4 rectangles with 50% height 50% width

开发者 https://www.devze.com 2023-01-20 10:34 出处:网络
I am having trouble splitting a screen into 4 divs with width and height of 50开发者_JAVA技巧%. It\'s no problem to get the 50% width and float them around, but how can I get each of them to have a he

I am having trouble splitting a screen into 4 divs with width and height of 50开发者_JAVA技巧%. 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%;
      }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号