Skip to content

reset less

危险

代码可能存在滞后

less
body {
  margin: 0;
  padding: 0;
  font-family: "Microsoft YaHei", "微软雅黑", "宋体", "Arial", "sans-serif";
}

body,
button,
input,
select,
textarea {
  font: 12px/1 system-ui, "Microsoft YaHei", "微软雅黑", "arial", "tahoma", "MicrosoftJhengHei",
    "sans-serif";
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased !important; /* 用 ascii 字符表示,使得在任何编码下都无问题 */
}

a {
  text-decoration: none;

  &:link,
  &:visited,
  &:hover {
    color: inherit;
    text-decoration: none;
  }
}

input {
  all: unset; /* 移除所有默认样式 */
  box-sizing: border-box; /* 让 padding 和 border 计算在 width 内 */
  font-family: inherit; /* 继承父级字体 */
  font-size: inherit; /* 继承字体大小 */

  appearance: none; /* 移除默认外观(对部分浏览器有效) */
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  padding: 0;
  margin: 0;

  &:focus {
    outline: none;
  }
}

button {
  all: unset; /* 移除所有默认样式 */
  background: transparent; /* 背景透明 */
  border: none; /* 移除默认边框 */
  font-family: inherit; /* 继承父元素字体 */
  font-size: inherit; /* 继承字体大小 */
  padding: 0; /* 去除内边距 */
  margin: 0; /* 去除外边距 */
  cursor: pointer; /* 使按钮可点击 */
  outline: none; /* 去除焦点框 */

  appearance: none; /* 去除系统样式 */
}

* {
  box-sizing: border-box;
}

ul,
li {
  list-style: none;
  margin: 0;
  padding: 0;
}