css 规则未在 safari 中应用,但在 firefox 中正常

标签 css twitter-bootstrap responsive-design

我想弄清楚为什么这条规则没有在 Safari 或 IE 中应用

.navbar-inner {
    min-height: 40px;
    padding-right: 20px;
    padding-left: 20px;
    background-color: #333333 !important;
    background-image: linear-gradient(to bottom, rgb(74, 74, 74), rgb(54, 54, 54)) !important;
    background-repeat: repeat-x;
    border: 1px solid rgb(212, 212, 212);
    border-radius: 4px 4px 4px 4px;
    box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.067);
}

基本上,我试图在 Bootstrap 中覆盖导航栏的背景颜色。 如您所见,我添加了 !important 关键字,只是为了测试 css 特异性问题。那仍然没有解决问题。 你能给我任何解决此问题的建议吗?它在 Firefox 中运行良好.... 我只是在 Chrome 中进行测试。

谢谢。

最佳答案

不同的浏览器使用不同的渐变属性。 This是一个非常好的生成它们的工具。

为此你可以使用:

.navbar-inner {
    background: rgb(74,74,74); /* Old browsers */
    background: -moz-linear-gradient(top, rgb(74,74,74) 1%, rgb(54,54,54) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,rgb(74,74,74)), color-stop(100%,rgb(54,54,54))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, rgb(74,74,74) 1%,rgb(54,54,54) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, rgb(74,74,74) 1%,rgb(54,54,54) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, rgb(74,74,74) 1%,rgb(54,54,54) 100%); /* IE10+ */
    background: linear-gradient(to bottom, rgb(74,74,74) 1%,rgb(54,54,54) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4a4a4a', endColorstr='#363636',GradientType=0 ); /* IE6-9 */
}

!important 在尝试覆盖 Bootstrap 默认样式时不应该是必需的。只需确保在自定义样式之前将您的 Bootstrap 样式添加到页面。

关于css 规则未在 safari 中应用,但在 firefox 中正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15689381/

相关文章:

html - 使用 CSS 选择性显示内容,避免冲突

css - 根据页面宽度更改背景图像不透明度

html - 如何在响应式表格内设置文本 - 单元格和表格的纵横比应为 1 :1

javascript - 获取 CSS 类的一部分作为字符串?

jquery - 将 jqGrid 和 bootstrap 与内联编辑混合在一起

css - 与 gwt Uibinder 一起使用带有背景图像集的 css

html - Bootstrap 2 模态框在一页上?

jquery - Bootstrap 模式中带有链接的远程内容

html - CSS 悬停不起作用

jquery - Bootstrap 中两行的 Logo 和菜单