新浪初始化css
html,body,ul,li,ol,dl,dd,dt,p,h1,h2,h3,h4,h5,h6,form,fieldset,legend,img { margin: 0; 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: 0; padding-bottom: 0; font-family: "SimSun","宋体" } input::-moz-focus-inner { border: 0; 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 }
京东的初始化html
* { margin: 0; padding: 0 } em,i { font-style: normal } li { list-style: none } img { border: 0; vertical-align: middle } button { cursor: pointer } a { color: #666; text-decoration: none } a:hover { color: #c81623 }
一、其实每一个网站的重置样式应该都是不一样的。
二、没有必要的样式或者是会再次对这个标签写样式的时候,浏览器就会二次渲染,因此也要尽可能的减小重置样式。
三、咱们应该合理灵活的使用标签,在网页中有些样式是如出一辙的,好比全部或者是大部分的文本p标签中字体样式同样并且行高也同样,那么能够统一设置。包括其余标签,在大量使用的过程当中能够统一设置margin,padding,width,height,display,text-align等,这样能够减小css样式,代码简洁,可读可改性高。web
一、重置css能够总体的调整整个网站的基本样式,好比网页占据的大部分字体样式,字体大小,字体颜色,还有最基本的有序无序列表和a连接的样式。
二、在一批拥有一样的头部脚部的样式中,我会把公共的样式放在重置样式表里。
三、还有针对网站的个别标签的样式特殊处理,好比我全部的a连接都应该是蓝色的等。
四、在须要大幅度使用的样式的时候,会另取一个类名主要针对须要此样式的标签,好比flyLeft{float:left};,flyRight{float:right};向左向右浮动的样式,或者是清除浮动的样式。浏览器
body, dl, dd, h1, h2, h3, h4, h5, h6, p, form{ margin: 0; } ol,ul{ margin: 0; padding: 0; } li{ list-style: none } input,button,textarea{ padding: 0; } /*另外:button和input自己有2px的边框,textarea和select自己有1px的边框,根据实际状况调整,或是去掉边框*/ table{ /*为表格设置合并边框模型*/ border-collapse: collapse; /*设置表格边框之间的空白*/ border-spacing: 0px; } /*去掉a连接的下划线*/ a{ text-decoration: none; } a:hover{ text-decoration: none; } /*个别浏览器对语义化标签的兼容*/ header, section, footer, aside, nav, main, article, figure { display: block; } h1,h2,h3,h4,h5,h6,em,i,b,cite { /*字体样式不加粗*/ font-weight: normal; font-style: normal; } a,input,button { /* 清除点击阴影 */ -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } body * { /* 选中文字设置 */ -weibkit-user-select: none; /* 禁止文字缩放 */ -webkit-text-size-adjust: 100%; }