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+ */
}
这篇关于在不改变整体宽度的情况下添加填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!