首先我们需要了解一下为什么需要公共样式(公共样式是为了初始化某些标签的默认值):

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

 2.初始化CSS样式主要是提高编码质量,如果不初始化整个页面做完很糟糕,重复的CSS样式很多。

一.PC端公共样式

这里参考的是I'm QQ(https://im.qq.com/index.shtml)的公共样式,其实对比一下其他大型网站的公共样式也类似:

html,body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:;padding:;font-family:Helvetica, Tahoma, Arial, "Hiragino Sans GB", "Hiragino Sans GB W3", "Microsoft YaHei", STXihei, STHeiti, Heiti, SimSun, sans-serif; font-size:100%;}
html,body{color:#333}
body{background:#fff;overflow-x: hidden;}
ul,ol,li{ list-style:none;}
a:link, a:visited{ color:#333; text-decoration:none;}
a:hover{ color:#12b7f5;}
img{ border:none;}
em{ font-style:normal;}
h1,h2,h3,h4,h5{ font-weight:normal;}
.clearfloat:after{ content:'.';display:block;overflow:hidden;visibility:hidden;font-size:;line-height:;width:;height:;}
.clearfloat{zoom:;}
二.移动端公共样式
之前开发的时候,移动端和PC公用一个css公共样式,不过看到别人分享的移动端公共样式,主要是多了对html5新标签的样式初始化及以下兼容处理,下次可以试一下.
/*reset*/
html{-webkit-text-size-adjust:100%;}
/*reset*/
html{max-width: 640px;margin:0 auto;}
article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, figure, section, legend, textarea, p, blockquote, th, td, input, select, textarea, button { margin:; padding: 0 }
fieldset, img { border: 0 none }
body{font:14px/1.4 "Microsoft Yahei",Arial,Helvetica,sans-serif;background-color: #fff;color:#333;max-width: 640px;margin: 0 auto;}
h1,h2,h3,h4,h5,h6{font-size:100%;font-weight: normal;}
table{border-collapse:collapse;border-spacing:}
ul,ol,dd,dt,dl{list-style-type:none;}
a{color:#333;text-decoration: none;-webkit-touch-callout: none;-webkit-user-select: none;}
a,input,select{-webkit-tap-highlight-color: transparent;-webkit-appearance: none;-moz-appearance: none;-webkit-border-radius:;} input,img{border:none;}
i,em{font-style:normal;}
:focus{outline: none}
select{ background: none } /*iphone6*/
@media(min-device-width:375px)and(max-device-width:667px)and(-webkit-min-device-pixel-ratio:2){body{font-size:14.5px;}}
/*iphone6plus*/
@media(min-device-width:414px) and (max-device-width:736px) and (-webkit-min-device-pixel-ratio:3){body{font-size:15.5px;}} /*原子类*/
.clear { clear: both; }
.clear:after { display: block; clear: both; visibility: hidden; height:; overflow: hidden; content: "."; }
.fl { float: left; }
.fr { float: right; }
.mb10{margin-bottom: 10px;}
.mt10{margin-top: 10px;}
/*placeholder css*/
::-moz-placeholder{ font-family: "Microsoft YaHei"}
::-webkit-input-placeholder{ font-family: "Microsoft YaHei"}
:-ms-input-placeholder{ font-family: "Microsoft YaHei"}

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, menu, nav, output, ruby, section, summary, time, mark, audio, video, input {
margin:;
padding:;
border:;
font-size: 100%;
font-weight: normal;
vertical-align: baseline;
} .divider {
height: 16px;
width: 100%;
background: #f3f5f7;
border-top: 1px solid rgba(7, 17, 27, 0.1);
border-bottom: 1px solid rgba(7, 17, 27, 0.1);
} /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, menu, nav, section {
display: block;
} body {
line-height:;
} blockquote, q {
quotes: none;
} blockquote:before, blockquote:after, q:before, q:after {
content: none;
} table {
border-collapse: collapse;
border-spacing:;
} /* custom */ a {
color: #7e8c8d;
text-decoration: none;
-webkit-backface-visibility: hidden;
} li {
list-style: none;
} ::-webkit-scrollbar {
width: 5px;
height: 5px;
} ::-webkit-scrollbar-track-piece {
background-color: rgba(0, 0, 0, 0.2);
-webkit-border-radius: 6px;
} ::-webkit-scrollbar-thumb:vertical {
height: 5px;
background-color: rgba(125, 125, 125, 0.7);
-webkit-border-radius: 6px;
} ::-webkit-scrollbar-thumb:horizontal {
width: 5px;
background-color: rgba(125, 125, 125, 0.7);
-webkit-border-radius: 6px;
} html, body {
width: 100%;
} body {
-webkit-text-size-adjust: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}


初始化css文件的更多相关文章

  1. 初始化CSS

    为什么要初始化CSS? 建站老手都知道,这是为了考虑到浏览器的兼容问题,其实不同浏览器对有些标签的默认值是不同的,如果没对CSS初始化往往会出现浏览器之间的页面差异.当然,初始化样式会对SEO有一定的 ...

  2. vue脚手架使用swiper /引入js文件/引入css文件

    1.安装vue-cli 参考地址:https://github.com/vuejs/vue-cli 如果不使用严格语法需要在后三项打no:(加了挺头疼的,老是报错,但是对自己的代码规范性也是有很大的帮 ...

  3. JavaScript使用localStorage缓存Js和css文件

    对于WebApp来说,将js css文件缓存到localstorage区可以减少页面在加载时与HTTP请求的交互次数,从而优化页面的加载时间.特别是当移端信号不好高延迟时优化效果还是很显见的 下面的代 ...

  4. yui压缩JS和CSS文件

    CSS和JS文件经常需要压缩,比如我们看到的XX.min.js是经过压缩的JS. 压缩文件第一个是可以减小文件大小,第二个是对于JS文件,默认会去掉所有的注释,而且会去掉所有的分号,也会将我们的一些参 ...

  5. SpringMVC里静态网页不能加载到.js .css文件的问题

    在写SpringMVC项目时候,写的js css文件打不开,网上查了一下,解决办法: 在web.xml里面: <servlet> <servlet-name>dispatche ...

  6. vue引入swiper vue使用swiper vue脚手架使用swiper /引入js文件/引入css文件

    vue引入swiper  vue使用swiper  vue脚手架使用swiper /引入js文件/引入css文件 ------------------------------------------- ...

  7. js文件 与 css文件 异步加载

    使用lazyload 异步加载css js 文件. 提升页面初始化的速度,减少卡顿时间 , 下面是 使用方法 与 lazyload.js 源码 (中文注释) 调用方法后. 会追加到 head 标签末尾 ...

  8. js或css文件后面的参数是什么意思?

    经常看到不少导航网站测样式或js文件后面加了一些参数,主要是一你为一些并不经常更新的页面重新加载新修改的文件. 经常遇到页面里加载的js与css文件带有参数,比如: <script type=& ...

  9. MVC学习随笔----如何在页面中添加JS和CSS文件

    http://blog.csdn.net/xxjoy_777/article/details/39050011 1.如何在页面中添加Js和CSS文件. 我们只需要在模板页中添加JS和CSS文件,然后子 ...

随机推荐

  1. html5之history对象理解

    history对象之pushState,replaceState浏览器有一个history对象,用来保存浏览历史,用户可以通过点击浏览器的后退或前进按钮在历史记录中切换.之前对history的操作的A ...

  2. windows8.1 初体验

    昨天装了Win8.1,Office2013 由于是英文版的,需要装一下中文语言包,然后就能使用自带的微软拼音输入法了. 我喜欢双屏时的桌面背景,选择span时一张图片可以跨越2个屏幕,比win7的好. ...

  3. 【Mac】使用PicGIF制作gif动态图片

    动态图片是我们常常需要的,mac系统下制作gif图片,可以使用PicGIF,AppStore中有一个简单版本免费的 环境与工具 1.mac系统 2.PicGIF Lite(可以在AppStore下载) ...

  4. 2018.10.16 NOIP模拟 长者(主席树+hash)

    传送门 考试的时候开始sb的以为需要可持久化trietrietrie树,发现建树时空都是O(n2)O(n^2)O(n2)的. 然后发现由于每次只从原来的字符串改一个字符. 因此直接主席树维护区间has ...

  5. 2018.07.06 POJ2536 Gopher II(二分图匹配)

    Gopher II Time Limit: 2000MS Memory Limit: 65536K Description The gopher family, having averted the ...

  6. [K8S]kubeadm国内镜像安装方式

    使用国内镜像站 sudo apt-get update && sudo apt-get install -y apt-transport-https curl sudo curl -s ...

  7. memmove、memcpy、strcpy、memset的实现

    memmove.memcpy.strcpy.memset 原型为: void *memmove( void* dest, const void* src, size_t count ); char*  ...

  8. 怎样使用word2013发布csdn博客

    目前大部分的博客作者在用Word写博客这件事情上都会遇到以下3个痛点: 1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.使用Word写 ...

  9. (最小生成树 )还是畅通工程 -- HDU--1233

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1233 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  10. Java性能调优:利用JFR生成性能日志

    Java性能调优作为大型分布式系统提供高性能服务的必修课,其重要性不言而喻. 好的分析工具能起到事半功倍的效果,利用分析利器JMC.JFR,可以实现性能问题的准确定位. 本文主要阐述如何利用JFR生成 ...