How do the CSS top bottom left and right attributes work?

后端 未结 3 1544
你的背包
你的背包 2021-01-25 04:20

I was wondering what the logic was behind the CSS attributes for top, left bottom and right.

for exa

3条回答
  •  -上瘾入骨i
    2021-01-25 04:35

    The float properties are relative to other elements in your document. The top, right, left, and bottom properties are relative to the edge of that element. They add margin of that amount to the specified side of the element.

    float: left; says "I'm going to float to the left of other elements next to me.

    right: 5px; says "The closest element has to be 5px away from me when on the right side.

    It's a matter of selflessness vs. selfishness. See the W3C Wiki for more information.

    Also, keep in mind that top, right, left, and bottom properties only work when position is set.

提交回复
热议问题