几乎所有的网站都需要单独写初始化代码,自己写了一些网页,总结了一下常用的css初始化代码,希望能对大家有所帮助。
cssReset:
/*根据需求自己编写css初始化代码,可被不同页面引用*/
@charset "utf-8"; /*css字符编码*/
html {
color: #000; /*所有的字体均继承*/
background: #fff;
}
body,
div,
dl,
dt,
dd,
ul,
ol,
li,
h1,
h2,
h3,
form,
fieldset,
input,
textarea,
p,
blockquote,
th,
td {
margin: 0;
padding: 0;
}
/*只写网页布局所需用的标签,优化性能,减轻服务器负担*/
table {
border-collapse: collapse; /*合并单元格边框*/
border-spacing: 0; /*设置单元格边框之间的距离为0*/
}
s,
a {
text-decoration: none;
}
em,
strong,
b,
u,
i {
font-style: normal;
font-weight: normal;
}
ol,
ul {
list-style: none; /*清除小点*/
}
h1,
h2,
h3 {
font-size: 100%;
font-weight: normal; /*标题不加粗*/
}
input,
textarea,
select {
font-family: inherit; /*inherit不支持ie8*/
font-size: inherit; /*规定应该从父元素继承字体尺寸*/
font-weight: inherit;
*font-size: %100; /*兼容ie浏览器*/ /*%100表示默认大小*/
}
img {
border: 0 none; /*只写none(适用于ie)有兼容性问题*/
}
input {
border: 0 none; /*只写none(适用于ie)有兼容性问题*/
outline: 0;
}