A mnemonic for the order of CSS margin and padding shorthand properties

前端 未结 22 1529
长发绾君心
长发绾君心 2021-01-30 05:20

I can never remember the order of the shorthand property for setting the margin or padding in one declaration. That is:

margin-top:    2px;
margin-bottom: 4px;
m         


        
22条回答
  •  孤独总比滥情好
    2021-01-30 05:32

    TROUBLE is always a secondary reminder for me, since I first think of the clockwise direction but might need to remember where you start; however, the 3-value shorthand was always confusing me until I realized the middle, (or second) value needs to represent two values (the sides). So, three values - the 2nd being 2 values - helps me remember that.

提交回复
热议问题