html - 如何在没有填充区域的情况下为 div 设置背景

标签 html css

我在 CSS 上有这个类:

.mgmtError{ 
  width:716px; 
  float:left; 
  background-color:#FF0000; 
  padding:10px; 
  text-align:center;
} 

而且我想给不在填充区域的背景着色。 我尝试了 margin,但似乎它在 IE 上有一些问题。

还有其他解决方案吗?

最佳答案

你可以使用

background-clip: content-box;

还要确保使用 background-color 属性,而不是 background

关于html - 如何在没有填充区域的情况下为 div 设置背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5896351/

相关文章:

jquery - IE 中的 div 不显示 CSS 大纲

jquery - 可扩展面板将列向下推到平板设备上

javascript - 如果仅发生错误,则需要在提交后保留星级值

html - Bootstrap 子菜单插入符在 iPad 3 上不可见

html - <span> vs <figure> vs <area>

css - 从已发布的 Google 文档电子表格中删除页眉和页脚

asp.net - 如何 : Background image should remain static but the webpage on it must scroll down in asp. 网络

jquery - Powershell 调用-WebRequest ...|选择 -ExpandProperty 输入字段(并非所有 "inputfields"都显示)

jquery - .html() 和 .append() 哪个更快?

javascript - 无法读取未定义的属性 'Elements' - 在 JS 控制台中