css全局样式初始化

因为浏览器的兼容问题,不同浏览器对有些标签的默认值是不同的,如果没对CSS初始化往往会出现浏览器之间的页面显示差异。

当然,初始化样式会对SEO有一定的影响,但鱼和熊掌不可兼得,但力求影响最小的情况下初始化。

*最简单的初始化方法就是(不建议):

{padding: 0; margin: 0;} 

淘宝的样式初始化:

body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td { margin:0; padding:0; }
body, button, input, select, textarea { font:12px/1.5tahoma, arial, \5b8b\4f53; }
h1, h2, h3, h4, h5, h6{ font-size:100%; }
address, cite, dfn, em, var { font-style:normal; }
code, kbd, pre, samp { font-family:couriernew, courier, monospace; }
small{ font-size:12px; }
ul, ol { list-style:none; }
a { text-decoration:none; }
a:hover { text-decoration:underline; }
sup { vertical-align:text-top; }
sub{ vertical-align:text-bottom; }
legend { color:#000; }
fieldset, img { border:0; }
button, input, select, textarea { font-size:100%; }
table { border-collapse:collapse; border-spacing:0; } 

原文地址:https://www.cnblogs.com/dlm17/p/12641651.html

时间: 2024-08-28 15:01:22

css全局样式初始化的相关文章

vue中使用css全局样式

在stylus中使用: 1.在src目录下的assets文件中的styles文件中创建一个varibles.styl文件 2.在varibles.styl文件中书写代码 $bgColor = #00bcd4 3.在vue组件的style中引入全局样式 @import '../../../assets/styles/varibles.styl' 4.使用全局样式 .header{ background : $bgColor }  原生css中使用: 1.在src目录下的assets文件中的styl

BootStrap 之 CSS全局样式中的图片

使用 BootStrap 中的CSS全局样式,我们就可以不用自己定义CSS样式了. 响应式图片 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="

BootStrap 之 CSS全局样式中的表单

不使用BootStrap 之 CSS全局样式中的表单,自己也不定义CSS样式 <form> <div> <label>Email address</label> <input type="email" placeholder="Email"> </div> <div> <label>Password</label> <input type="p

BootStrap 之 CSS全局样式中的表格

不使用BootStrap 之 CSS全局样式中的表格,自己也不定义CSS样式 <table> <caption>学生信息表</caption> <tr> <th>编号</th> <th>姓名</th> <th>性别</th> <th>操作</th> </tr> <tr> <td>1</td> <td>令狐

css全局样式表

/*==全局样式==*/*{padding:0;margin:0;}div,dl,dt,dd,form,h1,h2,h3,h4,h5,h6,img,ol,ul,li,table,th,td,p,span,a{border:0;}img,input{border:none;vertical-align:middle;}body{font-family:Tahoma,Arial,Helvetica,"宋体";font-size:12px;text-align:center;backgrou

bootstrap之CSS全局样式

一.排版样式(paiban) 1.标题标签 <body style="padding:20px"> <h1>h1.bootstrap</h1><br/> <h2>h2.bootstrap</h2><br/> <h3>h3.bootstrap</h3><br/> </body> 2.页面主体 <p>.....</p>   段落标签 中

CSS全局样式

@charset "utf-8"; * { margin:0; padding:0; }body{ font-family: "宋体",Arial,sans-serif; font-size: 14px; color:#000; text-align:center; }ul,ol,li { list-style-type:none; }img { border:0 none; }a { color:#000; text-decoration:none; }h1,h2

css全局样式基础代码

body{ font-size:12px; font-family:"宋体",Arial, Helvetica, sans-serif;color:#363636;background:#e5e5e5 url(../images/bpbg.jpg) center top no-repeat;}html, body, div, span, h1, h2, h3, h4, h5, h6, em, img, strong, sub, sup, tt,dd, dl, dt, form, lab

web前端入门到实战:css样式初始化

为了消除各浏览器对css默认的设置,保持网页在各浏览器中的外观保持一致,初始化css就显得非常必要了!很多时候出现的样式不兼容问题,都可以通过css初始化代码来解决. 1.最耗资源的,最简单的 * { padding: 0; margin: 0; border: 0; } 2.选择性初始化举例(综合) body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,legend,button form,fieldset,input,textarea,p