DAY50--CSS positioning

Source: Internet
Author: User

<position> tags are used to position elements, that is, to define the position of the element

Relative positioning:

1 <! DOCTYPE html>2 3 4 <style type= "Text/css" >5 H2.left{6 position:relative;# relative used to generate relatively positioned elements7  Left:-20px;# Indicates a left offset of 20px relative to normal position8}9 H2.right{Ten position:relative;# relative used to generate relatively positioned elements One  Left:20px;# Indicates a right offset of 20px relative to normal position A} - </style> -  the  - <body> -  - 

+

- </body> +

Absolute positioning

1 <! DOCTYPE html>2 3 4 <style type= "Text/css" >5 H2{6 position:Absolute;# Absolute for generating absolutely positioned elements7  Left:100px;# Indicates the distance from the leftmost 100px8 Top:150px;# indicates the top 150px distance9}Ten </style> One  A  - <body> -  the </body> - 

DAY50--CSS positioning

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.