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

Fixed position using CSS

WBOY
Release: 2023-09-01 12:57:03
forward
1216 people have browsed it

使用 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>
Copy after login

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

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template