reset css是什么

reset css是指reset.css重置浏览器标签的样式表,其作用就是将浏览器的默认样式全部去掉,更准确说就是通过重新定义标签样式,也就是把浏览器提供的默认样式覆盖掉。

reset css是什么

本文操作环境:windows7系统、CSS3版,DELL G3电脑

reset.css 重置浏览器标签的样式表

HTML标签在浏览器里有默认的样式,例如 p 标签有上下边距,strong标签有字体加粗样式,em标签有字体倾斜样式。不同浏览器的默认样式之间也会有差别,例如ul默认带有缩进的样式,在IE下,它的缩进是通过margin实现的,而Firefox下,它的缩进是由padding实现的。

在切换页面的时候,浏览器的默认样式往往会给我们带来麻烦,影响开发效率。所以解决的方法就是一开始就将浏览器的默认样式全部去掉,更准确说就是通过重新定义标签样式。“覆盖”浏览器的CSS默认属性。最最简单的说法就是把浏览器提供的默认样式覆盖掉!这就是CSS reset。

立即学习“前端免费学习笔记(深入)”;

重置作用

因为浏览器的品种很多,每个浏览器的默认样式也是不同的,比如

最简单的CSS Reset内容寥寥几行就能完成:

* { padding: 0; margin: 0; border: 0; }

登录后复制

(但由于性能较低,不推荐使用)

这个方法让所有的选择器的padding、margin和border都设置成0。也有内容更多的,比如YUI的CSS Reset内容:

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {padding: 0;margin: 0;}table {border-collapse: collapse;border-spacing: 0;}fieldset,img {border: 0;}address,caption,cite,code,dfn,em,strong,th,var {font-weight: normal;font-style: normal;}ol,ul {list-style: none;}caption,th {text-align: left;}h1,h2,h3,h4,h5,h6 {font-weight: normal;font-size: 100%;}q:before,q:after {content:'';}abbr,acronym { border: 0;}

登录后复制

以及国外名人Eric Meyer的CSS Reset V1.0|200802内容:

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, font, 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 {margin: 0;padding: 0;border: 0;outline: 0;font-size: 100%;vertical-align: baseline;background: transparent;}body {line-height: 1;}ol, ul {list-style: none;}blockquote, q {quotes: none;}blockquote:before,blockquote:after,q:before, q:after {content: '';content: none;}/* remember to define focus styles! */:focus {outline: 0;}/* remember to highlight inserts somehow! */ins {text-decoration: none;}del {text-decoration: line-through;}/* tables still need 'cellspacing="0"' in the markup */table {border-collapse: collapse;border-spacing: 0;}

登录后复制

Eric Meyer V2.0|20110126

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;}

登录后复制

大家可以看得出来,这些内容方法不同,但功能大同小异,都是起到重置的作用,所以说CSS Reset是根据个人需求不同可以按需自定义的。

推荐学习:《css视频教程》

以上就是reset css是什么的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2950673.html

(0)
上一篇 2025年3月11日 23:29:34
下一篇 2025年2月21日 12:59:43

AD推荐 黄金广告位招租... 更多推荐

相关推荐

  • css中reset重置样式的代码实现

    本篇文章给大家带来的内容是关于如何使用纯CSS3实现图片轮播的效果,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。 重置样式,清除浏览器默认样式,并配置适合设计的基础样式(强调文本是否大多是粗体、主文字色,主链接色,主字体等…

    编程技术 2025年3月10日
    200
  • css reset是什么意思?

    html标签在浏览器中都有默认的样式,例如p标签有上下边距,strong标签有字体加粗样式等。不同浏览器的默认样式之间存在差别,例如ul默认带有缩进样式,在ie下,它的缩进是由margin实现的,而在firefox下却是由padding实现…

    2025年3月10日
    200

发表回复

登录后才能评论