css - 在 Twitter Bootstrap CSS 中为背景图像覆盖 `background: transparent !important`

标签 css twitter-bootstrap twitter-bootstrap-3 background-image

我遇到了这个 question 中提到的相同问题,但对于 background-image,该问题的答案只支持用某种纯色而不是图像填充整个 div

我的情况是,我有一组 div,我给每个不同的 background-image,如下所示:

@media print {
  .AdultDentalChart .tooth .toothImage1 {
    background-image: url("@Url.Content("~/images/DentalChart.png")") !important;
    background-position: 0px 10px;
    -webkit-print-color-adjust: exact;
  }

请记住,我在 Bootstrap 中面临需要覆盖的相同代码

* {
    color: #000 !important;
    text-shadow: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

最佳答案

您在media print 中有两个@@ 删除其中一个。正如 OP 所评论的那样,这必须归因于正在使用的框架。 - 不是问题

使用background-image时必须设置width/height

CSS,来自级联,所以 div 必须在通配符选择器 * 之后才能覆盖它。

当然,该演示没有使用 print

@media {
  * {
    color: #000 !important;
    text-shadow: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  div {
    background-image: url("//dummyimage.com/200x200") !important;
    background-position: 0px 10px;
    -webkit-print-color-adjust: exact;
    height: 200px;
    width: 200px;
  }
}
<div>text</div>

关于css - 在 Twitter Bootstrap CSS 中为背景图像覆盖 `background: transparent !important`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38038013/

相关文章:

html - 图像悬停使用 html 或 css

html - 如何使我的网格模板行适合内容?

javascript - wny popover 不显示在 Angular js 中?

css - 防止导航栏过早换行

javascript - Joomla - Bootstrap 无法正常工作

css - Bootstrap 3 中的按钮边距 : where did they come from?

jquery : Onclick of a div - get id of following div

css - 如何在 Bootstrap 折叠标题中居中/对齐文本/图标按钮?

html - 为 Bootstrap 导航栏元素添加白色背景

twitter-bootstrap - 带有输入组的 Bootstrap 面板