reset css是什么
时间:2021-05-18
来源:互联网
标签:
今天PHP爱好者为您带来reset css是指reset.css重置浏览器标签的样式表,其作用就是将浏览器的默认样式全部去掉,更准确说就是通过重新定义标签样式,也就是把浏览器提供的默认样式覆盖掉。希望对大家有所帮助。

reset css是什么
本文操作环境:windows7系统、CSS3版,DELL G3电脑
reset.css 重置浏览器标签的样式表
HTML标签在浏览器里有默认的样式,例如 p 标签有上下边距,strong标签有字体加粗样式,em标签有字体倾斜样式。不同浏览器的默认样式之间也会有差别,例如ul默认带有缩进的样式,在IE下,它的缩进是通过margin实现的,而Firefox下,它的缩进是由padding实现的。
在切换页面的时候,浏览器的默认样式往往会给我们带来麻烦,影响开发效率。所以解决的方法就是一开始就将浏览器的默认样式全部去掉,更准确说就是通过重新定义标签样式。“覆盖”浏览器的CSS默认属性。最最简单的说法就是把浏览器提供的默认样式覆盖掉!这就是CSS reset。
重置作用
因为浏览器的品种很多,每个浏览器的默认样式也是不同的,比如<button>标签,在IE浏览器、Firefox浏览器以及Safari浏览器中的样式都是不同的,所以,通过重置button标签的CSS属性,然后再将它统一定义,就可以产生相同的显示效果。
最简单的CSS Reset内容寥寥几行就能完成:
* { padding: 0; margin: 0; border: 0; }
(但由于性能较低,不推荐使用)
这个方法让所有的选择器的padding、margin和border都设置成0。也有内容更多的,比如YUI的CSS Reset内容:
body,p,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, p, 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, p, 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是根据个人需求不同可以按需自定义的。
以上就是reset css是什么的详细内容,更多请关注php爱好者其它相关文章!
-
Ext.MessageBox消息框使用详解 时间:2025-11-20 -
GAppProxy超详细安装配置教程 时间:2025-11-20 -
C#中e.Cancel用法详解 e.Cancel和e.Handled区别 时间:2025-11-20 -
TestDirector超详细下载、安装、配置教程 时间:2025-11-20 -
AssemblyInfo.cs文件详解(常见属性及作用等) 时间:2025-11-20 -
什么是无理数 常见的无理数有哪些 无理数和有理数的区别 时间:2025-11-19
今日更新
-
上班摸鱼是什么梗?揭秘职场人高效偷懒的幽默生存法则,轻松get办公室快乐秘籍!
阅读:18
-
学信网学历快速查询-个人学历认证入口(一键查验)
阅读:18
-
币安风控触发永久限制?揭秘账户安全关键点
阅读:18
-
《高达:钢铁之诗》官网入口
阅读:18
-
币安杠杆交易风控规避指南 38字
阅读:18
-
2023上半年最这首梗吗梗大盘stelio达咩AI绘画爆火全网
阅读:18
-
《神探诡事录》手游官网正式入口
阅读:18
-
币安风控是否涉及KYC验证?关键解析与优化指南
阅读:18
-
学信网学籍查询-官方入口快速查(在线验证学籍状态)
阅读:18
-
币安风控处理慢?5招快速联系客服解决账户问题
阅读:18










