Home >Web Front-end >CSS Tutorial >Absolute positioning using CSS

Absolute positioning using CSS

WBOY
WBOYforward
2023-09-04 12:21:02729browse

使用 CSS 进行绝对定位

Elements with the following positions: Absolute Located at the specified coordinates relative to the upper left corner of the screen.

You can use the two values ​​top and left em> together with the position attribute to move an HTML element to any position within the HTML document.

  • Move left - use negative values > Left.
  • Move right - Use positive values ​​for left.
  • Move up - use negative values ​​for the top.
  • Move down - use positive values ​​for the top.

Example

You can try running the following code to achieve absolute positioning -
<html>
   <head>
   </head>
   <body>
      <div style = "position:absolute; left:80px; top:20px; background-color:yellow;">
         This div has absolute positioning.
      </div>
   </body>
</html>

The above is the detailed content of Absolute positioning using CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete