如何覆盖用户代理样式? [英] How to override the user-agent styling?

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

问题描述

我正在开发一个网页,该网页上我使用的是CSS样式表,而不是嵌入式样式.问题是,当我检查页面的chrome中的元素时,我可以看到几乎所有元素都继承了某些用户代理样式.我什至无法取消选中属性值. div {display:block} ,在Devtools的styles部分中,位于 user agent stylesheet 部分下,就像其余样式一样.

I am working on a webpage, where I am using css stylesheets instead of inline styling. The problem is, when I do inspect element in chrome for the page, I can see almost all elements inherit some user-agent styling. I can't even uncheck the attribute values eg. div{display: block}, in the styles section of the DevTools under user agent stylesheet sections, like I can with the rest of the styling.

我该如何解决?或者更好的是如何删除用户代理样式?

How do I fix this? Or better how do I remove the user-agent styling?

推荐答案

用户代理样式表只是元素随附的默认样式.

The user agent stylesheet is just the default styling that elements come with.

任何适用于元素的CSS规则都将覆盖用户代理样式表中的值.

Any CSS rule that applies to an element will override the values from a user agent stylesheet.

因此,只需编写一个规则集,其中包含一个与元素匹配的选择器,一个与您要更改的内容相匹配的属性以及一个正确的有效值.

So just write a ruleset with a selector that matches the element, with a property that matches what you want to change and a valid value for that properly.

div {
    display: inline;
}

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

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