Format and layout of HTML static Web pages (position: (fixed, absolute, relative), layered, float (left, right))

Source: Internet
Author: User

First, position:fixed

  Lock the location (relative to the browser's location), such as the pop-up window in the lower-right corner of some sites.

Example:

Second, Position:absolute

1. There is no position:absolute (or relative) in the outer layer, so the div is positioned relative to the browser, such as B (50 pixels from the right border of the browser and 20 pixels from the bottom).

2. The outer layer has position:absolute (or relative), so the div is positioned relative to the outer border, such as medium BB (50 pixels from the right border of D, and 20 pixels from the lower border of D).

Example:

Third, position:relative

  Move relative to the default position.

For example, a in the position before moving with relative, AA is the position after moving with relative, AA distance from the original position is 50 pixels, and the left margin of the original position is 20 pixels.

Example:

Iv. Layering (Z-index)

  Layered in the direction of z-axis, it can be understood to be divided into a stack of paper, the higher the number of layers on top.

In the example above, we saw that AA relative A, because the post code shows a higher level of display, so how do you make a cover AA without changing the code order? As follows:

Example:

V. Float:left, right

Overflow:hidden;//out part hidden; Scroll, display scroll bar;

<div style= "Clear:both" ></div>//Cutoff

To set the style of a hyperlink example:

Attached: Cursor:pointer the mouse to the top of the shape

&copy copyright Symbol ©

Translucent effect:

<div class= "box" > Transparent area <div>

The code in the style sheet is:

. box

{

opacity:0.5; -moz-opacity:0.5; Filter:alpha (OPACITY=50)

}

Formatting and layout of HTML static Web pages (position: (fixed, absolute, relative), layered, float (left, right))

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.