CSS setting code for one row and two columns

Source: Internet
Author: User
The code is as follows: Copy code

<Style type = "text/css">
Body {font-size: 12px ;}

. Main {width: 800px;/* total width */
Background: yellow;
}
. Main. col-1 {
Float: left;/* This is the key place for col1 to float to the left, so that other elements (other elements: div, image, text )*/
Width: 300px; height: 300px;
Background: # eee; border: 1px solid # ccc;
}
. Main. col-2 {
Float: left;/* This is the key place for col2 to move to the left, followed by col1 */
Margin-left: 5px;/* interval between col2 and col1 */
Width: 490px; height: 300px;/* give a random size */
Background: # ddd;
Border: 1px solid # ccc;
}
. Clear-float {clear: both}/* clear the float of col1 and col2. Otherwise, the height of the main will fail and there will be no float elements in it. */
</Style>

<Div class = "main"> main is the div of the package.
<Div class = "col-1"> col1 is the first column </div>
<Div class = "col-2"> col2 is the second column </div>
<Div class = "clear-float"> clear-float; I used to clear float </div>
</Div>

Related Article

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.