0

我正在构建一个性能至关重要且迄今为止最重的 css-selector 的站点

* {
  margin: 0;
  padding: 0;
}

有没有更便宜的方法可以在不失去此选择器提供的便利的情况下删除所有边距和填充?

更新:是的,使用经过测试的库是个好主意,但如果有人能证明数据“更便宜”,我将不胜感激

4

5 回答 5

2

尝试以这种方式列出所有元素(更多信息http://meyerweb.com/eric/tools/css/reset/):

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
}
于 2013-10-07T08:52:26.537 回答
1

是的,选择真正需要更改的元素。这更便宜,我在所有项目中都使用它:

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
}
于 2013-10-07T08:50:48.383 回答
1

看看一些框架,比如 Boilerplatte 或 Bootstrap。它们都在其 CSS 中具有重置条目,并且已知针对性能进行了优化。

于 2013-10-07T08:52:35.100 回答
0

是的,使用 css reset ,这就是我使用的,您可以根据要使用的元素制作自己的

/* http://meyerweb.com/eric/tools/css/reset/ 
  v2.0 | 20110126
  License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}

table {
border-collapse: collapse;
border-spacing: 0;
 }
于 2013-10-07T08:54:50.283 回答
-2

不,您无法对此选择器执行任何操作来显着提高性能。

于 2013-10-07T08:52:42.040 回答