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;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、基础知识篇:Http Header之User-AgentUser Agent中文名为用户代理,是Http协议中...
    iPhone阅读 15,851评论 0 13
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,868评论 18 139
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,790评论 1 92
  • 二话不说,先放效果图: 先介绍一下这个试水的小项目,就是上次搞那个express文件路由:express-dir-...
    CharTen阅读 12,384评论 11 48
  • 文/五月微醺 (微信/五月微醺) 图片/来自网络 “你说我是你眼里永远的小孩。 而我想说的是, 现在的你, 在我...
    五月微醺阅读 339评论 0 1