什么是用户代理样式表? [英] What is a user agent stylesheet?

查看:199
本文介绍了什么是用户代理样式表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Chrome浏览器中的网页.它可以正确显示以下样式.

I'm working on a web page in Google Chrome. It displays correctly with the following styles.

table {
    display: table;
    border-collapse: separate;
    border-spacing: 2px;
    border-color: gray;
}

请注意,我没有定义这些样式,这一点很重要.在Chrome开发人员工具中,它说用户代理样式表代替CSS文件名.

It is important to note that I didn't define these styles. In Chrome developer tools, it says user agent stylesheet in place of the CSS file name.

现在,如果我提交表单并且发生一些验证错误,则会得到以下样式表:

Now if I submit a form and some validation error occurs, I get the following stylesheet:

table {
    white-space: normal;
    line-height: normal;
    font-weight: normal;
    font-size: medium;
    font-variant: normal;
    font-style: normal;
    color: -webkit-text;
    text-align: -webkit-auto;
}

table {
    display: table;
    border-collapse: separate;
    border-spacing: 2px;
    border-color: gray;
}

这些新样式中的font-size干扰了我的设计.有没有办法强制我的样式表,并且在可能的情况下完全覆盖Chrome的默认样式表?

The font-size from these new styles is disturbing my design. Is there a way to force my stylesheets and if possible, completely overwrite Chrome's default stylesheet?

推荐答案

目标浏览器是什么?不同的浏览器设置不同的默认CSS规则.尝试添加CSS重置,例如 meyerweb CSS重置 normalize.css ,以删除这些默认设置. Google将CSS重置与归一化"以查看差异.

What are the target browsers? Different browsers set different default CSS rules. Try including a CSS reset, such as the meyerweb CSS reset or normalize.css, to remove those defaults. Google "CSS reset vs normalize" to see the differences.

这篇关于什么是用户代理样式表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆