[CSS3] Study notes--CSS box model

Source: Internet
Author: User

1. CSS Box Model overview

The content range of the box model includes: Margin (margin), border (border), padding (padding), content (contents) parts.

2. Inner margin

The padding is within the content, border, with 5 attributes:

padding: Set all margins

Padding-bottom: Set Bottom margin

Padding-left: Set the left margin

Padding-right: Set the right margin

Padding-top: Set Top margin

3. Border

We can create well-performing borders and can be applied to any element. The style of the border is Border-style, which defines 10 different non-inherited styles, including none.

4. Outer margin

The area around the content outer box is the margin, the margin is the transparent area by default, and the margin accepts any length unit or percentage value. Margin Common properties:

Margin: Set all margins

Margin-bottom: Set Bottom margin

Margin-left: Set the left margin

Margin-right: Set the right margin

Margin-top: Set Top margin

5. Outer margin Synthesis

If two boxes are the same, their margin is 100px, the boxes are arranged up and down, and the margin between the boxes is automatically synthesized, 100px, not 200px.

6. Box Model Application

1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4     <MetaCharSet= "UTF-8">5     <title>Application of Box model</title>6     <Linkhref= "1.css"type= "Text/css"rel= "stylesheet">7 </Head>8 <Body>9     <Divclass= "Top">Ten         <Divclass= "Top_content"></Div> One     </Div> A     <Divclass= "Body"> -         <Divclass= "Body_img"></Div> -         <Divclass= "Body_content"> the             <Divclass= "Body_no"></Div> -         </Div> -     </Div> -     <Divclass= "footing"> +         <Divclass= "Footing_content"></Div> -         <Divclass= "Footing_subnav"></Div> +     </Div> A </Body> at </HTML>

The corresponding CSS file:

1 *{2 margin:0px;3 padding:0px;4}5 . Top{6 width:100%;7 Height:50px;8 Background-color:Black;9}Ten . Top_content{ One width:75%; A Height:50px; - margin:0px Auto; - Background-color:Blue; the} - . Body{ - margin:20px Auto; - width:75%; + Height:1500px; - Background-color:Blanchedalmond; +} A . Body_img{ at width:100%; - Height:400px; - Background-color:Darkorange; -} - . Body_content{ - width:100%; in Height:1100px; - Background-color:Blueviolet; to} + . Body_no{ - width:100%; the Height:50px; * Background-color:Aqua; $}Panax Notoginseng . Footing{ - width:75%; the Height:400px; + Background-color:Coral; A margin:0px Auto; the} + . Footing_content{ - width:Auto; $ Height:330px; $ Background-color:Chartreuse; -} - . Footing_subnav{ the width:Auto; - Height:70px;Wuyi Background-color:Black; the}

[CSS3] Study notes--CSS box model

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.