html - 如何在不使用 960gs 的内部 div 的情况下向 div 添加填充?

标签 html css

我正在使用 960gs,并试图在不使用内部 div 的情况下向 div 添加填充。

你看,如果你给实际的 div 添加填充,它会破坏 960gs 创建的布局,我发现解决这个问题的唯一方法是创建另一个 div 并对其应用填充。

我猜这个方法没有问题,我只是发现第二个 div 是不必要的,我宁愿不使用它......有什么想法吗?

最佳答案

box-sizing 不起作用吗?

https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

div {
    width: 100px;
    box-sizing: border-box;
}

border-box The width and height properties include the padding and border, but not the margin. This is the box model used by Internet Explorer when the document is in Quirks mode.

关于html - 如何在不使用 960gs 的内部 div 的情况下向 div 添加填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4312263/

相关文章:

html - 如何调整 CSS 中每个 <br> 处两行之间的间距?

javascript - 是否有一种 document.createElement 多个元素的简写方式?

javascript - jQuery UI 选项卡,其中选项卡及其内容填充 100% 的可用空间

javascript - 如何在 JavaScript 中找到的 div 中获取特定类的元素?

css - 为什么这个非常简单的 CSS 不起作用?

javascript - 从 div id 中删除字符

html - 如何驯服 SVG 作为背景图像

html - SEO 对响应式网站指定图像宽度和高度的影响?

php - 文本区域中的跨浏览器兼容回车

html - chrome 中 div 之间的奇怪空间