css样式样式初始化:

145 阅读2分钟

每种浏览器内核对于html标签的css样式解释不一致,将会导致盒子的外边距,内边距,边框的设置不一致。还有超链接文本等样式不一致等。 解决方法:

html {
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
    font-size: 100px;
}

body {
    color: #4d4f53;
    line-height: 1.5;
    font-size: 14px;
    font-family: 'PingFangSC-Regular', 'helvetica neue', tahoma, 'PingFang SC', 'microsoft yahei', arial, 'hiragino sans gb', sans-serif;
    -webkit-font-smoothing: antialiased;
}

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,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td {
    margin: 0;
    padding: 0;
}

button,
input,
optgroup,
select,
textarea {
    color: inherit;
    font: inherit;
    margin: 0;
    padding: 0;
    border: 0;
    background: 0;
}

button:focus,
input:focus,
optgroup:focus,
select:focus,
textarea:focus {
    /*设置没有文本修饰(默认也是none)*/
    text-decoration: none;
    /*移动端 当点击一个链接或者通过Javascript定义的可点击元素的时候,它就会出现一个半透明的灰色背景,这里设置颜色为黑色*/
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    /*去掉文本框获取焦点是的蓝色框*/
    outline: none;
}

textarea {
    /*去掉多行文本框拖拽功能*/
    resize: none;
}

img {
    border: 0;
    /*通过设置图片与文字底线对齐,来消除图片底部空白间隙*/
    vertical-align: bottom;
}

a {
    text-decoration: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    /*消除下划线*/
    outline: none;
}

a,
a:hover,
a:active,
a:visited,
a:link,
a:focus {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-tap-highlight-color: transparent;
    outline: none;
    background: none;
    text-decoration: none;
}

ul,
li {
    /*清除列表小圆点*/
    list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-size: 100%;
    font-variant: normal;
}

/*clearfix 清除浮动*/
.clearfix:before,
.clearfix:after {
    content: "";
    display: table;
}

.clearfix:after {
    clear: both;
    overflow: hidden;
}

/*自定义清除边距类*/
.clear-p-t {
    padding-top: 0 !important;
}

.clear-margin {
    margin: 0 !important;
}

.clear-b-margin {
    margin-bottom: 0 !important;
}

.light {
    color: #0052D9;
}

.p-light {
    padding-left: 5px;
}