Home  >  Article  >  Web Front-end  >  Fixed position using CSS

Fixed position using CSS

WBOY
WBOYforward
2023-09-01 12:57:031161browse

使用 CSS 固定位置

Fixed positioning allows you to fix the position of an element to a specific location on the page, regardless of scrolling. The specified coordinates will be relative to the browser window.

You can use the two values ​​​​top and left and the position attribute to move an HTML element to any position in the HTML document.

  • Move left - Use negative values ​​ to move left.
  • Move right - Use positive left values.
  • Move Up - Use negative values ​​for the top.
  • Move down - Use positive values ​​for the top.
  • Move down - Use positive values ​​for the top.
  • li>

Example

You can try running the following code to achieve fixed positioning

 <html>
    <head>
    </head>
    <body>
       <div style = "position:fixed; left:80px; top:20px; background-color:blue;color:white;">
          This div has fixed positioning.
       </div>
    </body>
</html>

The above is the detailed content of Fixed position 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