在样式表中使用*选择器来重置样式 [英] Use of * selector in style sheet to reset styles

查看:183
本文介绍了在样式表中使用*选择器来重置样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我只是重置我需要在样式表顶部的样式,如:

At the moment I am just resetting the styles I need at the top of my style-sheet, like:

html, body, div, fieldset, form, h1, h2, h3, h4, p, ul, li {
    margin: 0;
    padding: 0;
}

然而,我已经看到很多次人们使用:

However, I have seen a lot of times that people use:

* {
    margin: 0;
    padding: 0;
}

这似乎使事情变得更容易,但在别的地方

That does seem to make things easier, but somewhere else (don´t remember where...) I read that using the * selector seriously affects performance.

这是真的,有一个长列表的选择器(这个例子只有几个选择器,

Is that true, does a long list of selectors (the example just has a few selectors, it could be more) perform significantly better than the * selector and are there perhaps other disadvantages to the * selector?

推荐答案

我曾经有过一次运行一些基准测试和* {}复位没有运行任何速度比重置 - 迈耶,YUI和没有任何重置。

I once ran some benchmarking and the *{} reset did not run any slower than the resets - Meyers, YUI and no reset at all.

* {}重置的主要问题是它重置大多数浏览器的输入按钮上的填充,但IE保留了一些填充,使得它很难一致样式的按钮跨浏览器。

The main problem with the *{} reset is that it resets the padding on the input buttons for most browsers but IE keeps some of its padding making it very hard to consistently style the buttons cross-browser.

这篇关于在样式表中使用*选择器来重置样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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