一、目的:为了消除各浏览器对css默认的设置,保持网页在各浏览器中的外观保持一致
1./* 把我们所有标签的内外边距边框清零,盒子为边框盒型,不会因为padding而变大 */
* {
margin: 0;
padding: 0;
boder:0
box-sizing: border-box;
}
(不建议,这样会加重网页渲染性能)
建议把项目中用到的标签都列出来,例如
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,legend,button
form,fieldset,input,textarea,p,blockquote,th,td {
padding: 0;
margin: 0;
boder:0
box-sizing: border-box;
}
/* 设置网页统一的字体大小、行高、字体系列相关属性 */
body {
font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei",
"Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif;
color: #333;
}
/* 去除默认的倾斜效果 */
em,
i {
font-style: normal;
}
2./* 清除列表样式 */
ol,ul {list-style: none;}
3.img {
/* 取消图片底侧有空白缝隙的问题 */
vertical-align: middle(也可以display:block)
}
button,input {
/* 当我们鼠标经过button 按钮的时候,鼠标变成小手,并且去除轮廓线,设置文字颜色 */
cursor: pointer;
outline: none;
color: #333;
}
/* 左浮动 */
.fl {
float: left;
}
/* 右浮动 */
.fr {
float: right;
}
a {
//清除a的下划线,并设置默认文字颜色
text-decoration: none
color: #333;
}
/* 双伪元素清除法 */
.clearfix::before,
.clearfix::after {
content: "";
display: table;
}
.clearfix::after {
clear: both;
}
//项目的版心
.w {
width: 1200px;
margin: 0 auto;
}
/* 设置表格的边框被合并为一个单一的边框, 指定分隔边框模型中单元格边界之间的距离为0*/
table {
border-collapse: collapse;
border-spacing: 0;
}