reset樣式(cssreset),解決瀏覽器默認(rèn)樣式(user agent style sheet)帶來的問題

用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;
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、基礎(chǔ)知識(shí)篇:Http Header之User-AgentUser Agent中文名為用戶代理,是Http協(xié)議中...
    iPhone閱讀 16,269評(píng)論 0 13
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,563評(píng)論 19 139
  • 問答題47 /72 常見瀏覽器兼容性問題與解決方案? 參考答案 (1)瀏覽器兼容問題一:不同瀏覽器的標(biāo)簽?zāi)J(rèn)的外補(bǔ)...
    _Yfling閱讀 14,153評(píng)論 1 92
  • 二話不說,先放效果圖: 先介紹一下這個(gè)試水的小項(xiàng)目,就是上次搞那個(gè)express文件路由:express-dir-...
    CharTen閱讀 12,472評(píng)論 11 48
  • 文/五月微醺 (微信/五月微醺) 圖片/來自網(wǎng)絡(luò) “你說我是你眼里永遠(yuǎn)的小孩。 而我想說的是, 現(xiàn)在的你, 在我...
    五月微醺閱讀 396評(píng)論 0 1

友情鏈接更多精彩內(nèi)容