CSS Firefox 特定边距?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6737175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:02:13  来源:igfitidea点击:

Firefox specific margin?

cssfirefoxmargin

提问by Matt

How can I set a specific margin for Firefox in CSS? I tried -moz-margin:0px;

如何在 CSS 中为 Firefox 设置特定边距?我试过 -moz-margin:0px;

My problem is in every browser, even IE works,

我的问题是在每个浏览器中,甚至 IE 都可以工作,

but firefox fails at my CSS now... There are certain links that move like 1px to the left when I rollover them...

但是firefox现在在我的CSS上失败了......当我滚动它们时,某些链接会向左移动1px......

回答by wanovak

Your problem probably lies elsewhere, but here's how you target Firefox only:

您的问题可能出在其他地方,但以下是您仅针对 Firefox 的方式:

@-moz-document url-prefix() {
    a {
        margin: 0;
    }
}

回答by Stanley Cup Phil

You can try something like this:

你可以尝试这样的事情:

@-moz-document url-prefix() { //Your css here }

@-moz-document url-prefix() { //Your css here }

That will only be read by Firefox.

这只会被 Firefox 读取。

Source

来源

回答by Aedaeum

To directly answer your question:

直接回答你的问题:

.myElement, x:-moz-any-link, x:default {
    margin: 0px;
}

This will set all elements with the 'myElement' class to a 0px margin within firefox only.

这会将所有具有 'myElement' 类的元素设置为仅在 Firefox 中的 0px 边距。