Web Front-end study notes, practice (4) CSS layout

Source: Internet
Author: User

In actual project development, the most possible layout method we use is floating layout. In fact, there is also an absolute positioning of the layout.

In web page technology, we can regard the plane as a piece of paper, and the lattice we need to draw can be arranged by the float attribute. Float has four attributes: Left, right, inherit, and none. When writing a floating-based page, you should also pay attention to clear the floating, You need to define a style class .. Clear {clear: Both ;}. How do I clear the float? You only need to add a blank structure in the structure. For example:

<Div class = "nav">

<Structure 1>

<Structure 2>

<Div class = "clear"> </div>

</Div>

In the floating layout, the left attribute is at the far left of the browser. The right attribute is on the rightmost side of the browser.Suggestion: In the same Dom, it is recommended that you do not use left right as a combination, and use an attribute as the benchmark.

Absolute positioning: This layout method appears in DHTML. Its Attribute scope is only in the position: relative; defined in the parent structure. Example:

Position: absolute; position: relative; the attribute has four optional values: Top left right bottom, which are respectively linked to the relative attribute of the parent container closest to it. Of course, there are positive and negative values.

. Nav {width: 965px; Height: 100px; position: relative ;}

. Dell {width: 200px; Height: 200px; position: absolute ;}

<Div class = "nav">

<Div class = "Dell"> </div>

</Div>

Dell Div, which can be active in a div with a width of 965px and a height of 100px (as you can imagine, it is active in it, with four coordinate values selected .)

Supplement: The position attribute also has a selection value. Position: fixed is used to define a value that is fixed in the browser and does not roll over ].

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.