特定于浏览器的 CSS 样式

标签 css google-chrome internet-explorer webkit margin

我有一个 CSS 类,如下

.sub-title
{
    -webkit-margin-before : 1em;
    -webkit-margin-start : 10px;
    margin: 10px 8px 2px 20px;
    overflow-wrap: break-word;
}

对于上面的类,我想为 div 应用边距。 在 IE 浏览器中我想应用“margin: 10px 8px 2px 20px;”在 Chrome 中,我想将边距应用为“-webkit-margin-before : 1em; -webkit-margin-start : 10px;"。

但即使在 Chrome 中,它也在考虑“margin: 10px 8px 2px 20px;”仅,而不是 webkit。

最佳答案

margin: 10px 8px 2px 20px; 放在 -webkit-margin-before : 1em;

之前

css 始终采用应用于元素的最后一个样式。在这种情况下,它将首先应用 margin: 10px 8px 2px 20px; ,然后应用 -webkit-margin-before : 1em; 。如果是 IE,第二行将被忽略。

.sub-title
{
    margin: 10px 8px 2px 20px;
    -webkit-margin-before : 1em;
    -webkit-margin-start : 10px;
    overflow-wrap: break-word;
}

关于特定于浏览器的 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32219394/

相关文章:

当你有多个相同的名字时,jquery 更改 1 div 的 css 类

javascript - <Button> 不适用于弹出窗口。 (HTML、CSS、JS)

html - 访问链接上的伪类

linux - 在Ubuntu下安装Google Chrome Stable 43.0.2357

internet-explorer - 不支持浏览器时显示消息

html - 列出 2 列

javascript - 使用 Google App Engine Flask dev_appserver.py 运行本地开发时,Chrome 不会刷新静态 JS 文件

node.js - CORS:预检通过,主请求完成 w/200,但浏览器仍然有 Origin 错误

HTML 列位移

css - IE定位问题