Html 如何使我的 CSS 代码与所有浏览器兼容?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12093540/
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-29 02:26:48  来源:igfitidea点击:

How can I make my CSS code compatible with all browsers?

htmlcsscross-browser

提问by Augustine Frendz

 p {
        margin:0;padding:0;
    }
    p#error {
        color:#FF0000;
        text-align:center;
    }
    p#success {
        color:#3983C2;
        text-align:center;
    }
    div#nav {
        background-image:url('../img/nav.png');
        background-repeat:no-repeat;
        padding-top:5px;
        padding-bottom:5px;
    }
    div#nav, a {
        text-decoration:none;
    }
    body {
        margin:0 auto;
        width:600px;
    }
    div#login, div#register {
        background-image:url('../img/form.png');
        background-repeat:repeat-y;
        padding-top:5px;
        padding-bottom:5px;
    }
    div#login table, div#register table {
        margin:0 auto;
    }
    div#login table td, div#register table td {
        text-align:right;
    }
    div#login input#btn, div#register input#btn {
        background-image:url('../img/btn.png');
        border-style:none;
        width:70px;height:25px;
    }
    div#footer {
        background-image:url('../img/footer.png');
        height:30px;
    }

Here is my CSS code. I don't know how to make this CSS work in other browsers, currently I'm working in Chrome. I already searched the net and found many pages with related information, but these are even more difficult for me to understand. Need your suggestions or etc. Thank you very much!

这是我的 CSS 代码。我不知道如何让这个 CSS 在其他浏览器中工作,目前我在 Chrome 中工作。我已经在网上搜索了很多相关信息的页面,但这些对我来说更难理解。需要您的建议等。非常感谢!

回答by Kris Hollenbeck

Your CSS should work in all browsers as is. It may not display the same from browser to browser. Most developers use a reset to fix that issue.

您的 CSS 应该可以在所有浏览器中正常工作。它可能会因浏览器而异。大多数开发人员使用重置来解决该问题。

CSS RESET

CSS重置

http://meyerweb.com/eric/tools/css/reset/

http://meyerweb.com/eric/tools/css/reset/

or

或者

NORMALIZE

正常化

http://necolas.github.com/normalize.css/

http://necolas.github.com/normalize.css/

回答by phunder

The problem is that each browser adds different default margins, padding, etc., to different items. This means that you get slightly, or greatly, different layouts in each.

问题是每个浏览器都会为不同的项目添加不同的默认边距、填充等。这意味着您会在每个布局中获得略微或非常不同的布局。

I like to do a CSS rest like this:

我喜欢做这样的 CSS 休息:

*{margin:0; padding:0}