开发者

CSS Left property

开发者 https://www.devze.com 2023-02-06 23:22 出处:网络
When you set something as left: 50px; in CSS, is the registrat开发者_C百科ion in the top left corner, or the center?Each one sets the registration point to whatever rule you\'re using.

When you set something as left: 50px; in CSS, is the registrat开发者_C百科ion in the top left corner, or the center?


Each one sets the registration point to whatever rule you're using.

If you only supply left or right the default registration point is top-left or top-right respectively.

So, for the various style rules:

Left/Left and Top = Top-left Corner

Right/Right and Top = Top-Right Corner

Left/Left and Bot = Bottom Left Corner

Right/Right and Bot = Bottom Right Corner


If the element has position:relative it will be moved 50px to the left from where it should be rendered. (y position is maintained)

If the element has position:absolute or position:fixed it will be positioned 50px to the left margin of the first of its' parents which has position set to anything but static.(if no such parents exist, it will be rendered 50px left of the beginning of the viewport)

If the element has no position attribute or position:static then the left,right,top,bottom attributes are ignored.

I believe most modern browsers will not modify the elements' y position unless explicitly stated.

0

精彩评论

暂无评论...
验证码 换一张
取 消