用ElementUI嘗試學(xué)習(xí)vue的時(shí)候,踩的坑。
發(fā)現(xiàn)自己在scoped樣式里面自己反復(fù)修改樣式,就是不起作用(*** 例如用個(gè)el-input組件,size="large",可是里面的字體還是小的可憐。 ),都快絕望之際,不得已用chrome的調(diào)試看下樣式到底怎么回事,原來是input的font樣式被一個(gè)叫user agent style sheet給綁架了,我設(shè)置的樣式?jīng)]有起到作用,雖然網(wǎng)上查資料,說這個(gè)user agent style sheet的優(yōu)先級(jí)很低,但是為啥很低有時(shí)候也能找到空子逆襲,把組件樣式給悄無聲息的偷掉呢?沒想明白。咨詢了google同志,原來大家為了防止這種情況,大家都用了CSSReset*, 聽起來好專業(yè),其實(shí)就是等于自己先交了張白卷,告訴瀏覽器你能想到的我已經(jīng)想到了,別在為我著想了. 更簡(jiǎn)單的說,就是把這個(gè)reset.css的樣式表作為樣式之一先導(dǎo)入就好了。貼出我找的一個(gè),其實(shí)我也不太懂原理,只知道這么用就好了。:
@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;
}