参考博客:https://blog.csdn.net/Ranchonono/article/details/68187642
https://www.cnblogs.com/tugenhua0707/p/5180841.html
https://blog.csdn.net/qq_33834489/article/details/79111172
https://blog.csdn.net/liwei26/article/details/78976444
一、常用reset.css如下:
清除不同浏览器之间的样式不统一,需对初始化默认样式,这里总结2种,本人习惯第一种,当然这种重置css在网上有很多,根据自己项目需求,选择合适就可。
1、
@charset "utf-8";
/* reset */
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td, section, article, aside, header, footer, nav, dialog, figure, hgroup { margin: 0; padding: 0;font-size:12px}
input, select, textarea { font-size: 100%; }
table { border-collapse: collapse; border-spacing: 0 }
fieldset, img { border: 0; }
caption, th { text-align: left; }
h1, h2, h3, h4, h5, h6 { font-size: 100%; font-weight: 500; }
ul, ol, li { list-style: none }
em, i { font-style: normal }
del { text-decoration: line-through; }
address, caption, cite, code, dfn, em, th, var { font-style: normal; font-weight: 500; }
img { border: 0; max-width: 100%; }
input, img { vertical-align: middle; }
input:focus, a:focus { outline: none; }
input[type="button"], input[type="submit"], input[type="reset"] { -webkit-appearance: none; outline: none; }
a { color: #353d44; text-decoration: none; cursor: pointer; }
a:active { opacity: .7; cursor: pointer; }
* { outline: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
html { -webkit-text-size-adjust: none; overflow-y: scroll; background-color:#f7f7f7;}
body{font-family:Helvetica;}
.clearfix:after{ content: ""; display: block; height: 0; clear: both; visibility: hidden; overflow: hidden; }
.clear { width: 0; height: 0; margin: 0; padding: 0; line-height: 0px; font-size: 0px; clear: both;}
.left{float: left;}
.right{float: right;}
2、
@charset "utf-8";
/* 防止用户自定义背景颜色对网页的影响,添加让用户可以自定义字体 */
html{
color: #000;
background: #fff;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
font-size: 100%;
}
/* IE6对positon:fixed的单独处理修正IE6滚动抖动的bug */
*html,*html body{
background-image:url(about:blank);/*修正IE6滚动抖动的bug*/
background-attachment: fixed;/*根据自己实际,非必需*/
}
/* 内外边距通常让各个浏览器样式的表现位置不同 */
body,div,dl,dt,dd,ul,li,pre,form,fieldset,select,input,textarea,button,p,blockquote,th,td,img,iframe{
margin: 0;
padding: 0;
}
body{
width: 100%;
}
/* 要注意表单元素并不继承父级 font 的问题 */
body,button,input,select,textarea{
font: 12px/1.5 "微软雅黑","Microsoft YaHei","\5b8b\4f53","Tahoma","Arial";
color: #333;
outline: none;
}
input,select,textarea{
font-size: 100%;
}
/* 重置button边框 */
button{
border: none;
}
/* 去掉各Table cell 的边距并让其边重合 */
table{
border-collapse: collapse;
border-spacing: 0;
}
/* IE bug fixed: th 不继承 text-align*/
th{
text-align: inherit;
}
/* 对齐是排版最重要的因素, 别让什么都居中 */
caption,th{
text-align: left;
}
/* 去除默认边框 */
fieldset,img{
border: none;
outline: none;
-moz-outline:none;
}
/* ie6 7 8(q) bug 显示为行内表现 */
iframe{
display: block;
}
/* 去掉列表前的标识, li 会继承 */
ol,ul,li{
list-style: none;
}
/* 来自yahoo, 让标题都自定义, 适应多个系统应用 */
h1,h2,h3,h4,h5,h6{
font-size: 100%;
font-weight: 500;
margin: 0;
padding: 0;
}
/* 让链接默认不显示下划线,在hover状态下显示下划线 */
a{
color: #333;
cursor: pointer;
outline: none;
text-decoration: none;
blr:expression(this.onFocus=this.blur());
}
a:hover{
text-decoration: underline;
}
/* 清理浮动 */
.clearfix:before,.clearfix:after{
display: block;
content: " ";
clear: both;
}
.clearfix{
zoom: 1; /* for ie67*/
}
/* 重设 HTML5 标签, IE 需要在 js 中 createElement(TAG) */
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{
display: block;
}
/* HTML5 媒体文件跟 img 保持一致 */
audio,canvas,video{
display: inline-block;
*display: inline;
*zoom: 1;
}
address,caption,cite,code,dfn,em,th{
font-style: normal;
font-weight: normal;
}
/*解决盒模型问题css3属性也可用来统一FORM元素风格*/
.box-sizing{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-o-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
2、移动端通用头部,适配尺寸
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="keywords" content="" />
<meta name="description" content="" />
<!-- 移动端 浏览器中页面将以原始大小显示,不允许缩放 -->
<meta name="viewport" content="width=device-width, viewport-fit=cover,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<!-- iphone会把一串数字识别为电话号码,点击的时候会提示是否呼叫,屏蔽这功能则把telephone设置为no -->
<meta content="telephone=no" name="format-detection" />
<title></title>
<link rel="stylesheet" href="../css/reset.css">
</head>
适配移动端尺寸需添加rem.js
<script type="text/javascript" src="../js/lib/rem.js"></script>