较好用的 CSS 初始化代码

CSS 重置(reset)指的是重置浏览器的默认样式,完成 CSS 初始化。
这是一个老外发的初始化 CSS 代码,比较符合我的使用习惯,简洁,不干涉太多,比较好用。

/*
  Josh's Custom CSS Reset
  https://www.joshwcomeau.com/css/custom-css-reset/
*/
*, *::before, *::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
html, body {
  height: 100%;
}
body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}
input, button, textarea, select {
  font: inherit;
}
p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}
#root, #__next {
  isolation: isolate;
}

最后那个 #root, #__next 是针对他自己使用的 next.js 用的,可以删除。

换色
阅读
登录
扫码