CSS divides a page evenly into four parts (div)

Source: Internet
Author: User

When you meet the requirements in your project, the data monitoring page needs to display 4 pieces of content simultaneously, such as:

How does CSS divide a page evenly into four parts (div)?

<! DOCTYPE html>{margin:0; padding:0; }. main{Width:100%; Height:100%;        Position:absolute; }. Quarter-div{Width:50%; Height:50%; float: Left; }. blue{Background-color: #5BC0DE; }. green{Background-color: #5CB85C; }. orange{Background-color: #F0AD4E; }. yellow{Background-color: #FFC706; }    </style>

As follows:

Due to the floating problem of the chart generated by the inner frame of the plate, there are problems with the above method, the improved method is as follows

CSS styles are as follows:

/* divide a page into 4 parts */ . clearfix:before,.clearfix:after{    display:table;    Content:"";}. clearfix:after{    Clear:both;}. clearfix{    *zoom:1;}. thewrap{    margin-top:16px;    Padding-left:20px;    Padding-right:20px;     100%;    Box-sizing:border-box;    Overflow:auto;}. Quarter-div{    50%;    Box-sizing:border-box;     float : Left;    Overflow:auto;}

JS Code:

<script>    $ (function() {        var bodyh = $ (window). Height ();        Console.log (BODYH);         var h = bodyh/2-70;        $ (". Quarter-div. Panel-body"). Height (h);    }); </script>

CSS divides a page evenly into four parts (div)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.