css - 什么情况下,padding比margin更好啊
PHP中文网
PHP中文网 2017-04-17 11:11:48
0
3
761

我们都知道 padding 和 margin 都可以用来定位,但是有时用 padding 比 margin 更好,比如margin 的上下边距合并。具体在那些情况下,用 padding 比用 margin 更好啊?

margin 和 padding 如何权重使用?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
阿神

I think this answer answers your question:

http://segmentfault.com/q/1010000000681376/a-1020000000681727

巴扎黑

For example, if a button has no padding, the text will be crowded

Also, for example, there is a small dot background image on the left side of the list, which can also be realized through padding of li

Generally, padding controls the internal margins, while margin controls the outer range. To actually position the element, margin is used. And inside the current element, how to play and position it, generally use padding

左手右手慢动作

First clarify the meaning of padding and margin. Why should one be better than the other? Internal margin padding is generally the distance between the element's content and the border; margin is the outer margin, which can be understood as the distance between the borders of multiple elements.

You will understand clearly if you look at the box diagram of the element in detail!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template