CSS Box Model Attribute Ordering Convention

前端 未结 2 1019
借酒劲吻你
借酒劲吻你 2021-01-01 05:44

If you ever wonder in what order to enter your CSS attributes like border, padding, font-family, etc. Two common approaches seem to be

2条回答
  •  暖寄归人
    2021-01-01 06:27

    It makes sense to:

    • Group the properties with similar functions (like height and width or clear and float) because if we change the value of one property, we often change the value of other properties in the group too.
    • Order the property groups such that they are in decision sequence. For example position before float, because if I choose position: absolute, float will be irrelevant.

提交回复
热议问题