目录

left

描述 (Description)

left属性定义绝对定位元素的左边缘与其定位上下文的左边缘的偏移量,或相对定位元素将被移位的水平距离。

可能的值 (Possible Values)

  • length - 距离定位上下文左侧的固定距离。

  • percent - 定义上下文宽度的某个百分比,假设已明确设置上下文的宽度。

  • auto - 默认。 让浏览器计算左侧位置。

适用于 (Applies to)

所有HTML定位元素。

DOM语法 (DOM Syntax)

object.style.left = "2px";

例子 (Example)

以下是显示此属性效果的示例 -

<html>
   <head>
   </head>
   <body>
      <p style = "position:absolute; left:100px;">
         This line will be positioned 100px away from the left edge of this window.
      </p>
   </body>
</html> 

它会产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018