简体   繁体   English

跨浏览器CSS需要“CSS重置”吗?

[英]Is a “CSS Reset” necessary for cross-browser CSS?

I've been trying to come up with a decent cross-browser CSS framework for my next project, because my last one had a whole bunch of PHP/CSS hacks (horrible things like class="blah<?=isIe()?>" ). 我一直在尝试为我的下一个项目提供一个不错的跨浏览器CSS框架,因为我的上一个有一大堆PHP / CSS黑客(像class="blah<?=isIe()?>"这样可怕的东西class="blah<?=isIe()?>" )。 I'd like to do it "right". 我想“正确”。 I've looked at this question , which did not get a lot of interest, so I'd like to narrow this down: is a CSS reset necessary for cross-browser formatting? 我已经看过这个问题这个问题并没有引起人们的兴趣,所以我想缩小范围:是否需要进行跨浏览器格式化的CSS重置? What about the Doctype? Doctype怎么样? Should one use 应该使用

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

or what? 或者是什么? Also, does anybody have any insight into the usefulness of Blueprint ? 此外,是否有人对蓝图的有用性有任何了解?

A CSS Reset isn't needed, but it does simplify things. 不需要CSS重置,但它确实简化了事情。

A Doctype is needed, without one browsers will enter Quirks mode and you open a big box of inconsistencies. 需要一个Doctype,没有一个浏览器会进入Quirks模式 ,你会打开一大堆不一致的东西。 The HTML 4.01 Strict Doctype you mention is a good choice, it is the most modern version of HTML that has decent support in the market. 你提到的HTML 4.01 Strict Doctype是一个不错的选择,它是最现代的HTML版本,在市场上有很好的支持。

A CSS reset isn't necessary, but it definitely helps a lot. CSS重置不是必需的,但它肯定有很多帮助。 It will make it so all elements are rendered the same in all browsers. 它将使所有元素在所有浏览器中呈现相同。

There are still certain things that will be slightly different due to each browser (mainly IE) rendering the box model differently. 由于每个浏览器(主要是IE)以不同的方式呈现盒子模型,因此仍然会有一些稍微不同的东西。 There are easier ways of doing browser specific CSS that inline class changes though. 有一些更简单的方法来执行内联类更改的浏览器特定CSS。 You can create an IE specific style sheet and just override the specific things you need changed. 您可以创建特定于IE的样式表,并覆盖您需要更改的特定内容。 You don't need PHP for this either. 你也不需要PHP。

<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->

You can can also use "lt" for < and "gt" for >. 您也可以使用“lt”代表<和“gt”代表>。

<!--[if lt IE 7]>
    <link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->

For me, doing a CSS reset has fixed 99% of my issues. 对我来说,进行CSS重置已修复了99%的问题。

Yahoo has a nice one. 雅虎有一个很好的。 http://developer.yahoo.com/yui/3/cssreset http://developer.yahoo.com/yui/3/cssreset

I've taken to always using a CSS reset and building back up from this base for my projects. 我总是使用CSS重置并从我的项目基础构建备份。 It simplifies things a lot as you no longer have to worry about differing default sizes, etc between browsers. 它简化了很多事情,因为您不再需要担心浏览器之间的默认大小等。 Besides, any sufficiently large project has a large amount of CSS reseting in it anyway, and in those projects not using a CSS reset sheet they will instead most likely have it split across lots of areas, badly done and buggy :) 此外,任何足够大的项目都会有大量的CSS重置,并且在那些没有使用CSS重置表的项目中,他们很可能会将它分成很多区域,糟糕的做法和错误:)

I tend to use the YUI CSS sheets for my projects but I may now check out Blueprint now it's been brought to my attention ;) 我倾向于为我的项目使用YUI CSS工作表,但我现在可以查看Blueprint,现在它引起了我的注意;)

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

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