html - Firefox 和 Chrome 的不同背景位置

标签 html css

我在 div 中使用图像作为背景,我想对 Firefox 和 Chrome 使用不同的定位。

我想将这个用于 Mozila:

background-position: left -14px bottom -1px !important;

我想将这个用于 Chrome:

background-position: left -14px bottom -2px !important;

这可能吗?请给我建议..

最佳答案

您可以为 FF 和 Chrome 使用特定的选择器:

以 Chrome 为目标:

@media screen and (-webkit-min-device-pixel-ratio:0) {
   .yourElement {
     background-position: left -14px bottom -2px !important;
   }
}

以 FF 为目标:

@-moz-document url-prefix() { 
  .yourElement {
    background-position: left -14px bottom -1px !important;
  }
}

这比使用用户代理要好得多。

关于html - Firefox 和 Chrome 的不同背景位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20989891/

相关文章:

javascript - 数组被视为对象,无法 NgFor

javascript - 使文本框出现在所选单选按钮旁边

html - anchor 标记中的 Iframe。是的,我知道。 IE渲染的问题

javascript - 在 HTML 电子邮件中使用 href 传递参数 c# MVC

javascript - 我如何在滑动选项卡中设置选项卡的起始位置以删除那里的滚动条?

javascript - 我如何使用/附加 pnotify 到一个 div

css - 文本相对于背景图像和外部容器的对齐方式

PHP 选项卡实现

css - 将 ul 中的事件 li 垂直居中

html - 如何在 CSS 中创建响应式箭头指针形状?