The absolute positioning and relative positioning of CSS style sheet of

Source: Internet
Author: User
Tags relative

Positioning attributes will be the key to the door of happiness that the web bugs open:
Absolute positioning

The code is as follows Copy Code
H4 {position:absolute; left:100px; top:43px}

This CSS rule allows the browser to set the starting position exactly 100 pixels to the left of the browser, 43 pixels from its top, and see how the code works.
Note that the only set here is the left and the top, which means that the text will go from left to right, from top to bottom, to the Browse window.
The left and top properties are intuitive, and the left setting is the distance from the left side of the browser window, and the top set to the top of the browser window.
When you set these distances, you can use the various degrees of units or proportions you have learned. When using proportional values, the proportional value is relative to the parent element's dimensions.
Relative positioning
Absolute positioning allows you to accurately position the elements in a separate location on the page, regardless of the positioning settings for other elements of the page. Relative positioning refers to the position of the element you are positioned in relation to the location assigned in the file. Cases:

The code is as follows Copy Code
I {position:relative; left:40px; top:10px}

Please click to see how the code works
The key to relative positioning is that the position of the element is positioned relative to where it should normally be located. If you stop using relative positioning, the display position of the text will return to normal. Example.
Use relative positioning to be careful, otherwise it is easy to make the page very messy.
In addition to relative positioning and absolute positioning, you can also use static (static) parameter values. It is used in the same way as the normal HTML positioning method, and cannot attach special positioning settings.

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.