CSS, nested divs & margins vs. padding

后端 未结 7 2229
攒了一身酷
攒了一身酷 2021-01-13 16:10

i totally understand the box model. this question is more about trying to pin down a semantic methodology regarding when to use margins and when to use padding.

her

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-13 16:24

    Personally, I prefer option A. Why? Say now I have to add other HTML elements into the div and I want the padding to be maintained, I would not have to add other rules to my CSS files to get it working.

提交回复
热议问题