CSS Reset 样式重置的实现示例

CSS Reset 样式重置的实现示例,第1张

CSS Reset 样式重置的实现示例

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


(如下需要梯子)

Chromium UA stylesheet -Google Chrome & Opera

Mozilla UA stylesheet - firefox

WebKit UA stylesheet - safari

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

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


html{
   /* 标准字体大小可以,在移动端使用的rem适配的话会动态改变。


*/ font-size:14px; /* 使用IE盒模型(个人取舍,我一般设置width是这是盒子的真实大小,包括padding和border) */ 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; /* 照着antd上面来的,在公司就别用微软雅黑了,不建议字体使用rem。


*/ 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;
   /* antd里面还做了 , 看你团队需不需要这样的风格 */
  transition: color 0.3s ease;
}

ol,
ul{
   /* 去除自带的ugly样式。


*/ 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;
}
 /* 取消部分浏览器数字输入控件的 *** 作按钮 apperance可以改变控件的外观。


*/ 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; } /** * 删除Firefox中的内边框和填充。


*/ button::-moz-focus-inner, [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner { border-style: none; padding: 0; } /** * 让html5中的hidden在IE10中正确显示 */ [hidden] { display: none; } template { /* 有些浏览器会显示template 不过template标签用的也少,自行取舍。


*/ display: none; }

css Reset地址

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


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


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/616876.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-15
下一篇 2022-04-15

发表评论

登录后才能评论

评论列表(0条)

保存