在不更改总宽度的情况下添加填充 [英] Add padding without changing overall width
本文介绍了在不更改总宽度的情况下添加填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不添加预定义宽度的情况下向元素添加填充?
How can I add padding to an element without adding on top of the predefined width?
最好定义列的宽度以为布局创建干净的网格;但还想在该列内的内容中添加填充.有什么方法可以指定吗?
It's good to define the width of a column to make a clean grid for the layout; but also wants to add padding to the contents inside the column. Any way to specify that?
推荐答案
element {
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
这篇关于在不更改总宽度的情况下添加填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文