新浪的初始化:

 html,body,ul,li,ol,dl,dd,dt,p,h1,h2,h3,h4,h5,h6,form,fieldset,legend,img {
margin:;
padding: 0
}
fieldset,img {
border: 0
}
img {
display: block
}
address,caption,cite,code,dfn,th,var {
font-style: normal;
font-weight: normal
}
ul,ol {
list-style: none
}
input {
padding-top:;
padding-bottom:;
font-family: "SimSun","宋体"
}
input::-moz-focus-inner {
border:;
padding: 0
}
select,input {
vertical-align: middle
}
select,input,textarea {
font-size: 12px;
margin: 0
}
input[type="text"],input[type="password"],textarea {
outline-style: none;
-webkit-appearance: none
}
textarea {
resize: none
}
table {
border-collapse: collapse
}

京东的初始化:

 * {
margin:;
padding: 0
}
em,i {
font-style: normal
}
li {
list-style: none
}
img {
border:;
vertical-align: middle
}
button {
cursor: pointer
}
a {
color: #666;
text-decoration: none
}
a:hover {
color: #c81623
}

大众版初始化:

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
margin:;
padding:;
border:;
outline:;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
h1,h2,h3,h4,h5,h6,em,i {
font-weight:;
font-style: normal
}
ul,ol,li {
list-style-type: none
}
a {
color: #666;
text-decoration: none;
outline: 0
}
a:hover {
text-decoration: none
}  

  看到这些是不是感觉自己平时也是这么写的?其实我之前也是这么写的,后来看到张鑫旭大神的文章后才知道有一种更好的写法,更简单、更高效。自己也已经亲测过了div、li、tr、td这种标签默认就没有margin和padding,dt标签的默认的margin和padding就是0,还有dfn, ins, kbd, q, samp, sub, sup, var这些标签平常我们网站上也用不到,所以就没必要重置,像京东这种一个 * 号全部重置,本着宁可错杀三千也不放过一个这么暴力的做法最好避免,不,应该是杜绝这种写法,不过大家在写一个简单的测试页面的时候可以暂时用一下,因为我平时也是这么写的,主要是快速不用写太多标签,注意只是测试暂时可以用一下。。。

  还有一些h1、h2、h3、h4、h5、h6这些标签也可以酌情处理,一般用到几个就写几个不用全部重置,像h1这个标签按其seo方面来考虑,一个页面最好只有一个,所以没必要开始的时候就重置其样式,等你按设计稿写样式的时候又重置一次,这样就相当于浏览器渲染了2次,完全没有必要,你可能会说这也没几个不会有什么影响,错,既然我们是做重构的就要本着能少则少的理念去做,如今时间就是金钱,即使提高0.1秒的载入时间我们也是有必要去争取的。

  网上特意搜了一下html标签的默认样式和浏览器默认样式,整理了一下有兴趣的可以看一下~

/*html标签默认样式*/
html, address,blockquote,body, dd, div,dl, dt, fieldset, form,frame, frameset,h1, h2, h3, h4,h5, h6, noframes,ol, p, ul, center,dir, hr, menu, pre { display: block }
/*以上列表元素默认状态下以块状显示,未显示的将以内联元素显示,该列表针对HTML4版本,部分元素在HTML5中已废弃*/
li { display: list-item }/*默认以列表显示*/
head { display: none }/*默认不显示*/
table { display: table }/*默认为表格显示*/
tr { display: table-row }/*默认为表格行显示*/
thead { display: table-header-group }/*默认为表格头部分组显示*/
tbody { display: table-row-group }/*默认为表格行分组显示*/
tfoot { display: table-footer-group }/*默认为表格底部分组显示*/
col { display: table-column }/*默认为表格列显示*/
colgroup { display: table-column-group }/*默认为表格列分组显示*/
td, th { display: table-cell; }/*默认为单元格显示*/
caption { display: table-caption }/*默认为表格标题显示*/
th { font-weight: bolder; text-align: center }/*默认为表格标题显示,呈现加粗居中状态*/
caption { text-align: center }/*默认为表格标题显示,呈现居中状态*/
body { margin: 8px; line-height: 1.12 }
h1 { font-size: 2em; margin: .67em 0 }
h2 { font-size: 1.5em; margin: .75em 0 }
h3 { font-size: 1.17em; margin: .83em 0 }
h4, p, blockquote, ul, fieldset, form, ol, dl, dir, menu { margin: 1.12em 0 }
h5 { font-size: .83em; margin: 1.5em 0 }
h6 { font-size: .75em; margin: 1.67em 0 }
h1, h2, h3, h4, h5, h6, b,strong { font-weight: bolder }
blockquote { margin-left: 40px; margin-right: 40px }
i, cite, em,var, address { font-style: italic }
pre, tt, code, kbd, samp { font-family: monospace }
pre { white-space: pre }
button, textarea, input, object, select { display:inline-block; }
big { font-size: 1.17em }
small, sub, sup { font-size: .83em }
sub { vertical-align: sub }/*定义sub元素默认为下标显示*/
sup { vertical-align: super }/*定义sub元素默认为上标显示*/
table { border-spacing: 2px; }
thead, tbody, tfoot { vertical-align: middle }/*定义表头、主体表、表脚元素默认为垂直对齐*/
td, th { vertical-align: inherit }/*定义单元格、列标题默认为垂直对齐默认为继承*/
s, strike, del { text-decoration: line-through }/*定义这些元素默认为删除线显示*/
hr { border: 1px inset }/*定义分割线默认为1px宽的3D凹边效果*/
ol, ul, dir, menu, dd { margin-left: 40px }
ol { list-style-type: decimal }
ol ul, ul ol, ul ul, ol ol { margin-top:; margin-bottom: 0 }
u, ins { text-decoration: underline }
br:before { content: ""A" }/*定义换行元素的伪对象内容样式*/
:before, :after { white-space: pre-line }/*定义伪对象空格字符的默认样式*/
center { text-align: center }
abbr, acronym { font-variant: small-caps; letter-spacing: 0.1em }
:link, :visited { text-decoration: underline }
:focus { outline: thin dotted invert }
/* Begin bidirectionality settings (do not change) */
BDO[DIR="ltr"] { direction: ltr; unicode-bidi: bidi-override}
/*定义BDO元素当其属性为DIR="ltr"时的默认文本读写显示顺序*/
BDO[DIR="rtl"] { direction: rtl; unicode-bidi: bidi-override}
/*定义BDO元素当其属性为DIR="rtl"时的默认文本读写显示顺序*/
*[DIR="ltr"] { direction: ltr; unicode-bidi: embed}
/*定义任何元素当其属性为DIR="ltr"时的默认文本读写显示顺序*/
*[DIR="rtl"] { direction: rtl; unicode-bidi: embed}
/*定义任何元素当其属性为DIR="rtl"时的默认文本读写显示顺序*/
@media print { /*定义标题和列表默认的打印样式*/
h1 { page-break-before: always }
h1, h2, h3, h4, h5, h6 { page-break-after: avoid }
ul, ol, dl { page-break-before: avoid }
} /*浏览器默认样式*/ //1、页边距
//IE默认为10px,通过body的margin属性设置
//FF默认为8px,通过body的padding属性设置
//要清除页边距一定要清除这两个属性值 body {
margin:;
padding:;
} //2、段间距
//IE默认为19px,通过p的margin-top属性设置
//FF默认为1.12em,通过p的margin-bottom属性设
//p默认为块状显示,要清除段间距,一般可以设置 p {
margin-top:;
margin-bottom:;
} //3、标题样式
//h1~h6默认加粗显示:font-weight:bold;。
//默认大小请参上表
//还有是这样的写的 h1 {font-size:xx-large;}
h2 {font-size:x-large;}
h3 {font-size:large;}
h4 {font-size:medium;}
h5 {font-size:small;}
h6 {font-size:x-small;} /*个大浏览器默认字体大小为16px,即等于medium,h1~h6元素默认以块状显示字体显示为粗体,要清除标题样式,一般可以设置*/ hx {
font-weight:normal;
font-size:value;
} //4、列表样式
//IE默认为40px,通过ul、ol的margin属性设置
//FF默认为40px,通过ul、ol的padding属性设置
//dl无缩进,但起内部的说明元素dd默认缩进40px,而名称元素dt没有缩进。
//要清除列表样式,一般可以设置 ul, ol, dd {
list-style-type:none;
margin-left:;
padding-left:;
} // 元素居中
// IE默认为text-align:center;
// FF默认为margin-left:auto;margin-right:auto; //5、超链接样式a 样式默认带有下划线,显示颜色为蓝色,被访问过的超链接变紫色,要清除链接样式,一般可以设置 a {
text-decoration:none;
color:#colorname;
} //6、鼠标样式
//IE默认为cursor:hand;
//FF默认为cursor:pointer;该声明在IE中也有效 //7、图片链接样式
//IE默认为紫色2px的边框线
//FF默认为蓝色2px的边框线
//要清除图片链接样式,一般可以设置 img {
border:;
}

  总结一下,我们写代码的时候可以参考别人的代码,找到自己需要的,不用全部都copy过来,即浪费代码又浪费性能。好了就到这里吧,如果文中有错误的地方还望指正,我们共同进步吧。

  今天周一上班感觉好困啊,如今天气冷了早上根本就起不来,有多少人跟我一样周一是一个迷糊的一天。。。

样式重置 css reset的更多相关文章

  1. 默认样式重置 (css reset)

    body,p,h1,h2,h3,h4,h5,h6,dl,dd,t{margin:0; font-size:12px;/* font-family:XX; */} ol,ul{list-style:no ...

  2. htmlcss笔记--标签默认值样式重置css reset

    1.<a>标签 有默认文字修饰:下划线, 去除:text-decoration:none; text-decoration属性值: none 默认.定义标准的文本. underline 定 ...

  3. htmlcss笔记--标签默认值样式重置css reset(2)

    1.内联,内嵌,行内元素: 默认可以继续跟同类型标签显示: 由内容撑开宽度,内容多宽,会有多宽: span,内嵌标签部支持宽高,即使加了宽高也不支持, 也不支持上下内外边距,但是支持左右内外边距:内上 ...

  4. 重置浏览器的默认样式(css reset)

    (1)定义:首先css reset指的是重置浏览器的默认样式 (2)作用:因为现在的浏览器很多,并且每个浏览器都有自己的默认样式,这样就会导致一个页面在多个浏览器下展示产生差异,所以我们需要做一些处理 ...

  5. 封装好通用的reset.css base.css 样式重置css文件

    一般是叫reset.css 我这边命名成base.css 哎呀无所谓…… @charset "UTF-8"; /*css reset*/ /*清除内外边距*/ body, h1, ...

  6. CSS工具、CSS重置(CSS Reset)

    样式重置的目的是减少浏览器的不一致性,例如line-height,margin,标题的font-size大小等等.样式重置经常在CSS框架中出现. 这里的重置样式故意写的很一般,例如没有为body元素 ...

  7. CSS工具之CSS重置(CSS Reset)

    css代码: /* v1.0 | 20080212 */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, ...

  8. reset.css(样式重置)

    CSS Reset,意为重置默认样式.HTML中绝大部分标签元素在网页显示中都有一个默认属性值,通常为了避免重复定义元素样式,需要进行重置默认样式(CSS Reset).举几个例子:1.淘宝(CSS ...

  9. CSS Reset(样式重置)

    CSS Reset,意为重置默认样式.HTML中绝大部分标签元素在网页显示中都有一个默认属性值,通常为了避免重复定义元素样式,需要进行重置默认样式(CSS Reset).举几个例子:1.淘宝(CSS ...

随机推荐

  1. 【转】将grub2安装到u盘的方法

    将grub2安装到u盘的方法 时间:2015-03-21来源:linux网站 作者:linux人 grub2在各大linux发行版中广泛采用,它非常强大,基本上大多数操作系统都是通过它引导起来的,它的 ...

  2. C标准头文件<errno.h>

    声明了错误处理相关的宏 errno errno即error number,在程序启动时被设为0,当某个库函数运行出现错误的时候,会将相应的能表达错误类型的数字赋值给这个左值,这些数字往往有相应的宏来表 ...

  3. Python (一) 简介、安装

    一.简介 Python:是著名的"龟叔"Guido van Rossum在1989年圣诞节期间,为了打发无聊的圣诞节而编写的一个编程语言. 那么Python 究竟是来做什么的? 首 ...

  4. ASP.NET MVC4入门到精通系列目录汇总

    序言 最近公司在招.NET程序员,我发现好多来公司面试的.NET程序员居然都没有 ASP.NET MVC项目经验,其中包括一些工作4.5年了,甚至8年10年的,许多人给我的感觉是:工作了4.5年,We ...

  5. 【问题】关于Mapper not initialized的问题

    ERROR -- ::, [ ] nHandling.AbpApiExceptionFilterAttribute - Mapper not initialized. Call Initialize ...

  6. datatables中的Options总结(1)

    datatables中的Options总结(1) 最近一直研究dataTables插件,下面是总结的所有的选项内容,用了帮助学习datatables插件. 这些选项的配置在$().Datatable( ...

  7. Java关键字final、static

    一.final根据程序上下文环境,Java关键字final有“这是无法改变的”或者“终态的”含义,它可以修饰非抽象类.非抽象类成员方法和变量.你可能出于两种理解而需要阻止改变:设计或效率. final ...

  8. Android 7.0 Nougat牛轧糖 发布啦

    Android 7.0 Nougat牛轧糖 发布啦 Android 7.0 Nougat 牛轧糖于本月发布了. 从官方blog里可以了解到这个版本的新特性. Android 7.0 从2016年8月正 ...

  9. IOS开发基础知识--碎片49

    1:iOS项目配置文件info.plist文件解析 Localization native development region本地化 Executable file可执行文件路径 Bundle id ...

  10. jQuery解决iframe高度自适应代码

    网上查了好多用着都不行,自己搞定了:在包含iframe的页面中加入以下脚本,基本思想是在iframe加载内容后重新设置高度,下面代码尽在IE6中用过,没在其他浏览器中测试. 代码如下: <scr ...