Css:css+div Layout Page

Source: Internet
Author: User

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

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.