开发者

Question about the relevance of margins or display properties for absolutely positioned or fixed positioned elements

开发者 https://www.devze.com 2023-03-13 03:17 出处:网络
If absolutely positioned or fixed positioned elements are taken out of the normal flow, is it still advisable to use margins to position those elements

If absolutely positioned or fixed positioned elements are taken out of the normal flow, is it still advisable to use margins to position those elements

or

would it be just the same if th开发者_如何学运维e [ top, right, bottom, left] position properties are used instead to move the elements around?


I would say it's not advisable.

The properties - top, right, bottom, left - exist to position such styled elements accordingly. Using margin, although may work, would not be the correct positioning property and could lead to undefined behavior.

With that said, there are obviously more than one way to do things in CSS. So in the end, it's up to you.

0

精彩评论

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

关注公众号