栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > Html/CSS > CSS教程

CSS Reset 样式重置的实现示例

CSS教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力



前言:所有浏览器都有附带的默认样式,这些样式应用在每一个页面,叫做“用户代理样式表”。(如下需要梯子)

Chromium UA stylesheet -Google Chrome & Opera

Mozilla UA stylesheet - firefox

WebKit UA stylesheet - safari

虽然大部分相同,但也有很多样式是不一致的,如搜索输入框



所以我们需要reset css处理,统一不同浏览器差异确认团队开发的起始标准,弥补浏览器的‘缺点’。

html{
   
  font-size:14px;
  
  box-sizing: border-box;
  
}

html,body{
   
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    
  -webkit-overflow-scrolling: touch;
  overflow-scrolling: touch;
   
  height: 100%;
}

body{
   
  background: #fff;
   
  font:14px,-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Hiragino Sans GB','Microsoft YaHei',
  'Helvetica Neue',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'
   
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

去除浏览器默认的margin和padding, 自行删减一些不必要的标签

body,
p,
h1,
h2,
h3,
h4,
h5,
h6,
dl,
dd,
ul,
ol,
th,
td,
button,
figure,
input,
textarea,
form,
pre,
blockquote,
figure{
margin: 0;
padding: 0;
}

a{
   
  cursor: pointer;
   
  text-decoration:none;
   
  transition: color 0.3s ease;
}

ol,
ul{
   
  list-style:none     
}

这些节点部分属性没有继承父节点样式,所有继承一下,并取消outline,外轮廓的效果

a,
h1,
h2,
h3,
h4,
h5,
h6,
input,
select,
button,
textarea {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
font-style: inherit;
line-height: inherit;
color: inherit;
outline: none;
}

button,
input[type='submit'],
input[type='button'] {
 
cursor: pointer;
}
 
input[type='number'] {
-moz-appearance: textfield;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
margin: 0;
-webkit-appearance: none;
}

button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
  border-style: none;
  padding: 0;
}


[hidden] {
  display: none;
}
template {
 
display: none;
}


css Reset地址

后续还会继续添加,小伙伴们一起吧。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/215028.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号