使用 CSS 进行相对定位

PHPz
PHPz 转载
2023-08-27 15:13:02 769浏览

使用 CSS 进行相对定位

  • 向左移动 - 对使用负值。
  • 向右移动 -向左使用正值。
  • 向上移动 -顶部使用负值。
  • 向下移动 - 顶部使用正值。
  • 示例

    您可以尝试运行以下代码来实现相对定位 -

    <html>
       <head>
       </head>
          <body>
             <div style = "position:relative;left:80px;top:2px;background-color:yellow;">
                This div has relative positioning.
             </div>
          </body>
    </html>

    以上就是使用 CSS 进行相对定位的详细内容,更多请关注php中文网其它相关文章!

    声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除