HTML Learning Notes (vi)

Source: Internet
Author: User

Yesterday ended the HTML+CSS part of the study.

Today is the 23, today's task is mainly to review the previous learning knowledge.

Here's a look at what you learned yesterday:

1.margin and Padding

Margin is used to control the margin of the label, margin has four attributes: in order, respectively, top right bottom left. If you set only 1 values, the margins in the four directions are the values. If you set a value of two, the two values represent the top and bottom margins, respectively. padding represents an internal margin usage similar to margin.

Overlap Phenomenon of 2.margin

Insert a section of code:

<title>Overlap of margin</title><style>#d1{Background-color:Red;Height:50px;Margin-bottom:30px;        }#d2{Background-color:Blue;Height:50px;Margin-top:20px;        }</style>    <Body><DivID= "D1"></Div><DivID= "D2"></Div></Body></HTML>

The spacing between the two Div is supposed to be 50px, but the margin overlap will allow the true spacing to take the maximum value of two margin.

3. Box model

Real Floor Width: width+padding*2+border*2+margin*2

Real Floor Height: height+padding*2+border*2+margin*2

4. Absolute positioning

According to the parent element who has the position attribute, according to who position, if the parent element of the previous level does not have the position attribute, will continue to search the top level, the maximum can find the body tag, according to the body to locate.

  

/     * Absolute positioning */        #b5 {            width:50px;            height:50px;            Background-color:blue;            Position:absolute;            top:50px;            left:50px;            z-index:101;        }        #b6 {            width:50px;            height:50px;            Background-color:brown;            Position:absolute;            top:40px;            left:40px;            z-index:100;        }            #b7 {            width:300px;            height:300px;            Background-color:pink;        }     </ style >

There is also a z-index attribute in absolute positioning, and if there are two blocks overlapping each other, you can use Z-index to adjust which one is on the bottom. The upper code sets the Z-index, and the final effect is a large value displayed on top.

5.fixed positioning and relative positioning

Fixed positioning is based on the browser window, such as the 360 site on the right side of the navigation bar.

Relative positioning is relative to its own position to locate.

<style>#b1{width:100px;Height:100px;Background-color:Orange;position:fixed;/*fixed, positioning according to browser window*/ Left:1000px;Top:50px;        }#b2{width:300px;Height:300px;Background-color:Green;        }#b3{width:100px;Height:100px;Background-color:Aqua;position:relative;/*relative positioning*/ Left:10px;Top:10px;        }#b4{width:100px;Height:100px;Background-color:Pink;        }</style><DivID= "B1">Fixed positioning</Div><DivID= "B2">relative positioning<DivID= "B3"></Div>    <DivID= "B4">    </Div>    </Div>

6. Block elements and inline elements

  

How to achieve the transformation of block elements and inline elements:

      

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><title>The transformation of inline elements and block elements</title><style>Div{width:200px;Height:200px;Background-color:Red;Border:1px solid Black;Display:inline;/*block to inline*/    }#s1{Color:Red;width:100px;Height:100px;Display:Block;/*Inline Turn block*/Background-color:Blue;    }</style></Head><Body>    <P>Away from the original<spanID= "S1">Grass</span>, the spring breeze blows again to live</P>    <Div>One year old one withered flourish</Div>    <Div>The wild Fire is endless</Div></Body></HTML>

HTML Learning Notes (vi)

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.