CSS basic Tutorial: two-column layout instance code

Source: Internet
Author: User

As the main language for making web pages today, css has become a must-have for every Webmaster. If you still don't know css, you are still using dw to create a table Page, your website may not be able to get effective seo and other performance optimizations, thus losing the market. Today, I recommend a basic tutorial for you. Every Webmaster can understand it.

First look at the css section:

Reference content is as follows:
# Wrap {
Border: 1px solid blue;
Margin: 0 auto;
Overflow: hidden;/* adds the overflow attribute to remove floating code so that the parent container can contain child layers. */
Width: 950px;/* The width here should also be set, instead of using the default adaptive width 100% of the browser */
}
# Content {
Border: 1px solid # C3CFEA;
Float: left;
Margin: 10px 0;
Overflow: hidden;
Padding: 10px 10px 15px;/* Note the padding settings here */
Width: 680px;/* Note that the width here only refers to the width of the content area of the layer. The actual width is 680px + 10px (right fill) + 10px (left fill) + 1px (Right Border) + 1px (left border) = 702 px ;*/
}
# Sidebar {
Border: 1px solid # FF0000;
Color: # FF0000;
Float: right;
Margin: 10px 0;
Overflow: hidden;
Padding: 0 10px 20px;
Width: 220px;/* the actual width is 220px + 10px + 10px + 1 + 1 = 242px */
}

The above css is used in HTML:

Reference content is as follows:
<Div id = "wrap">
<Div id = "content">
Content
</Div>
<Div id = "sidebar">
Sidebar
</Div>
</Div>

Note the width setting of the above layers: The condition 242px + 702px = 944px <950px must be met.

Let's look at the demo:

<Html> 

Tip: the code can be modified before running!

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.