reset样式(cssreset),解决浏览器默认样式(user agent style sheet)带来的问题

用ElementUI尝试学习vue的时候,踩的坑。

发现自己在scoped样式里面自己反复修改样式,就是不起作用(*** 例如用个el-input组件,size="large",可是里面的字体还是小的可怜。 ),都快绝望之际,不得已用chrome的调试看下样式到底怎么回事,原来是input的font样式被一个叫user agent style sheet给绑架了,我设置的样式没有起到作用,虽然网上查资料,说这个user agent style sheet的优先级很低,但是为啥很低有时候也能找到空子逆袭,把组件样式给悄无声息的偷掉呢?没想明白。咨询了google同志,原来大家为了防止这种情况,大家都用了CSSReset*, 听起来好专业,其实就是等于自己先交了张白卷,告诉浏览器你能想到的我已经想到了,别在为我着想了. 更简单的说,就是把这个reset.css的样式表作为样式之一先导入就好了。贴出我找的一个,其实我也不太懂原理,只知道这么用就好了。:

@charset "utf-8";
/*RESET v3*/
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, a, cite, img, sub, sup, 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, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
    border: 0;
    font: inherit;
    margin: 0;
    padding: 0;
    font-weight: normal;
    vertical-align: baseline;
}
html,body{
    height:100%
}
body {

}
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
    display: block;
}
button {
    outline: none;
}
ol, ul {
    margin: 0;
    padding: 0;
}
ol, ul, li {
    list-style: none;
}
i, em {
    font-style: normal;
}
blockquote {
    quotes: none;
}
blockquote:before, blockquote:after {
    content: '';
    content: none;
}
a {
    outline: none;
    text-decoration: none;
    text-decoration:none;
    text-decoration: none;
    transition: background-color .5s ease 0s,color .5s ease 0s,width .5s ease 0s,border-width .5s ease 0s,border-color .5s ease 0s;
    -webkit-transition: background-color .5s ease 0s,color .5s ease 0s,width .5s ease 0s,border-width .5s ease 0s,border-color .5s ease 0s;
    -moz-transition: background-color .5s ease 0s,color .5s ease 0s,width .5s ease 0s,border-width .5s ease 0s,border-color .5s ease 0s;
    -ms-transition: background-color .5s ease 0s,color .5s ease 0s,width .5s ease 0s,border-width .5s ease 0s,border-color .5s ease 0s;
    -o-transition: background-color .5s ease 0s,color .5s ease 0s,width .5s ease 0s,border-width .5s ease 0s,border-color .5s ease 0s
}
input, textarea{
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    outline: none;
    border: 0;
    margin: 0;
    padding: 0;
}
select, option{
    font-family: inherit;
}
.noselect{
    -webkit-user-select: none;
    user-select: none;
}
.clear {
    clear: both;
}
/*textarea,input,a{*/
/*-webkit-appearance: none;*/
/*}*/
.clearfix:before,.clearfix:after{
    content:"";
    display:table;
}
.clearfix:after{
    clear:both;
}
.clearfix{
    *zoom:1;
}

你可能感兴趣的:(reset样式(cssreset),解决浏览器默认样式(user agent style sheet)带来的问题)