简体   繁体   English

我们如何禁用元素的默认浏览器样式属性?

[英]How can we disable default browser style properties for elements?

Having issue in design on forms and links on a page I created because of the browser style properties. 由于浏览器样式的属性,我在创建的页面上的表单和链接上存在设计问题。 How can I disable it so that no elements in my html page gets affected by the browsers' default style property? 如何禁用它,以使html页面中的任何元素都不受浏览器的默认样式属性影响?

All solutions are welcome. 欢迎所有解决方案。 I am using php for development. 我正在使用php进行开发。 So all solutions with css, javascript, php etc are welcomed. 因此,欢迎使用css,javascript,php等所有解决方案。

You can maybe put !important behind the css you want to overwrite the default style properties? 您可以将!important放在要覆盖默认样式属性的CSS后面吗?

maybe this solves your solution? 也许这可以解决您的问题?

There must be a default style for all elements, so you cannot just disable them. 所有元素必须具有默认样式,因此您不能仅禁用它们。 The usual way to handle this issue is adding your desired defaults in a base CSS file, overwriting the browser's defaults. 解决此问题的常用方法是在基本CSS文件中添加所需的默认值,从而覆盖浏览器的默认值。

As @link commented, http://www.cssreset.com/ provides several default styles to be applied as base in your pages. 正如@link所评论的那样, http://www.cssreset.com/提供了几种默认样式,可以用作您页面的基础。

Please use normalize css : 请使用Normalize CSS:

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

It'll help you. 会帮你的。

You need to override browser's default stylesheet. 您需要覆盖浏览器的默认样式表。 You can do it many ways- 您可以通过多种方式做到这一点-

  • Manually define every elements style 手动定义每个元素样式
  • Use any reset.css (You can find many) 使用任何reset.css(您可以找到许多)
  • Use a basic html startup tamplate, which covers everything you need. 使用基本的html启动模板,它涵盖了您需要的所有内容。 You can find one here , It has many options to choose from. 您可以在这里找到一个,它有很多选择。

Hope you will love it :-) 希望你会喜欢它:-)

You cannot disable browser default style sheets, just override them by setting properties to specific values. 您不能禁用浏览器默认样式表,而只是通过将属性设置为特定值来覆盖它们。 It is common to confuse the two. 混淆两者是很常见的。

This is a decision by browser vendors. 这是浏览器供应商的决定。 They could give a page (scripts on a page) access to the browser's stylesheet allowing it or parts thereof to be disabled. 他们可以授予页面(页面上的脚本)访问浏览器样式表的权限,从而允许其或其部分被禁用。 But they haven't done that. 但是他们还没有做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM