Modern page layouts: css+div:
general Web pages are sequential layout, it is difficult to achieve the page layout format we need, at this time using a div for hierarchical layout, similar to the box, design Each part of the content. This is now the main page layout method, using DIV+CSS.
CSS Box Model:
The property names commonly heard in Web design: content, padding (padding), Border (border), border (margin), CSS box mode.
In CSS, box model is called Box models (or box models), and the box model specifies the way in which the element frame handles element content, padding (padding), Border (border), and margin (margin). In the HTML document, each element has a box model, so in the Web world (especially page layouts), box model is everywhere. Here is a diagram of the box model:
Explain:
Content: is the content of HTML, in the most inner layer
Inner border Padding:padding-top, Padding-right, Padding-bottom, Padding-left
Borders Border:border-top, Border-right, Border-bottom, Border-left
Margins Margin:marging-top, Margin-right, Margin-bottom, Margin-left
The padding, borders, and margins can be applied to all edges of an element or to individual edges. Also, margins can be negative, and in many cases negative margins are used.
The test demo is as follows:
Css_div.html
<!DOCTYPE HTML><HTMLLang= "ZH-CN"> <Head> <MetaCharSet= "Utf-8"> <Metaname= "description"conent= " This was an example"> <Metaname= "keywords"conent= "Css,div"> <title>CSS and div combo layouts</title> <Linkrel= "stylesheet"type= "Text/css"href= "Css_div.css"> </Head> <Body> <H1>CSS Box model</H1> <HR> <Divclass= "Wraper"> <Divclass= "Content"> <H2>This is a test</H2> <H2>This is a test</H2> <H2>This is a test</H2> </Div> </Div> </Body></HTML>
View Code
Css_div.css
H2{Color: White;margin:0;}. Wraper{/*outer*/margin:Auto;/*Box Model Center*/Height:500px;width:500px;Background-color:Red;padding:20px;}. Content{/*Inner Layer*/Height:300px;width:300px;Background-color:Blue;padding:20px;Border:Solid 4px White;Margin-top:50px;Padding-left:50px;}View Code
:
Css:css+div Layout Page