【前端项目规范】之base.css

122 阅读3分钟

pc端

html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
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 {
  margin: 0;
  padding: 0;
}

article,
aside,
footer,
header,
nav,
section,
figcaption,
figure,
main,
details,
menu,
hgroup,
div {
  display: block;
  box-sizing: border-box;
}

html {
  line-height: 1;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 
    tahoma, arial,
    "Hiragino Sans GB",
    "Microsoft YaHei",
    "WenQuanYi Micro Hei",
    STHeiti,
    "Droid Sans Fallback",
    SimSun,
    sans-serif;
  font-size: 12px;
  background-color: #fff;
  color: #333;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

a {
  font-size: 12px;
  text-decoration: none;
  color: #333;
  outline: none;
  transition: color 0.3s;
  background-color: transparent;
  -webkit-text-decoration-skip: objects;
  -webkit-backface-visibility: hidden;
}

a:hover {
  color: #999;
  outline: 0;
}

a:focus {
  text-decoration: none;
}

a:active {
  outline: 0;
}

img {
  border-style: none;
  outline: none;
  vertical-align: bottom;
}

ol,
ul {
  list-style: none;
}

b,
strong {
  font-weight: bolder;
}

button,
input,
optgroup,
select,
textarea {
  font-family: sans-serif;
  font-size: 100%;
  line-height: 1.15;
  margin: 0;
}

button,
input {
  overflow: visible;
}

button,
select {
  text-transform: none;
}

button,
html [type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
}

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

button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
  outline: 1px dotted ButtonText;
}

input,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
  padding: 0;
  color: inherit;
  border: 0;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #ccc;
}

input::-moz-placeholder,
textarea::-moz-placeholder {
  opacity: 1;
  color: #ccc;
}

input::-ms-input-placeholder,
textarea::-ms-input-placeholder {
  color: #ccc;
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  color: #ccc;
}

input::-ms-clear {
  display: none;
}

textarea {
  overflow: auto;
  resize: none;
}

[type="checkbox"],
[type="radio"] {
  box-sizing: border-box;
  padding: 0;
}

[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

[type="search"] {
  -webkit-appearance: textfield;
  outline-offset: -2px;
}

[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

figure {
  margin: 1em 40px;
}

hr {
  box-sizing: content-box;
  height: 0;
  overflow: visible;
}

pre,
code,
kbd,
samp {
  font-family: monospace, monospace;
  font-size: 1em;
}

abbr[title] {
  border-bottom: none;
  text-decoration: underline;
  text-decoration: underline dotted;
}

dfn {
  font-style: italic;
}

mark {
  background-color: #ff0;
  color: #000;
}

small {
  font-size: 80%;
}

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

audio,
video {
  display: inline-block;
}

audio:not([controls]) {
  display: none;
  height: 0;
}

svg:not(:root) {
  overflow: hidden;
}

fieldset {
  padding: 0.35em 0.75em 0.625em;
}

legend {
  box-sizing: border-box;
  color: inherit;
  display: table;
  max-width: 100%;
  padding: 0;
  white-space: normal;
}

progress {
  display: inline-block;
  vertical-align: baseline;
}

summary {
  display: list-item;
}

canvas {
  display: inline-block;
}

template {
  display: none;
}

blockquote,
q {
  quotes: none;
}

blockquote:before,
blockquote:after,
q:before,
q:after {
  content: "";
  content: none;
}

[hidden] {
  display: none;
}

h5端

在pc端的基础上加上以下内容

* {
  outline: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

body {
  font-family: -apple-system,Helvetica,sans-serif;
  ...
}

微信小程序

app.wxss

/* Module page
-------------------------------------------------- */
page {
  height: 100%;
  font: 28rpx/1.5 -apple-system, Helvetica Neue, sans-serif;
  color: var(--colorGrayDeep);
  background: var(--colorGrayF);
}

/* Module navigator
-------------------------------------------------- */
page .navigator-hover {
  opacity: 0.6;
  background: #fff;
}

page .hover {
  opacity: 0.6;
}

/* Module button
-------------------------------------------------- */
page button {
  display: inline-block;
  margin-left: 0;
  margin-right: 0;
  font-weight: normal;
  white-space: nowrap;
  vertical-align: top;
  /* default size button */
  font-size: 28rpx;
  height: 72rpx;
  line-height: 72rpx;
  padding: 0 24rpx;
}

page button::after {
  border: none;
}

page button.long {
  display: block;
}

page .button-hover {
  opacity: 0.6;
}

page button[size=mini] {
  font-size: 24rpx;
  height: 48rpx;
  line-height: 48rpx;
  padding: 0 16rpx;
}

page button[size=small] {
  font-size: 24rpx;
  height: 64rpx;
  line-height: 64rpx;
  padding: 0 16rpx;
}

page button[size=default] {
  font-size: 28rpx;
  height: 72rpx;
  line-height: 72rpx;
  padding: 0 24rpx;
}

page button[size=middle] {
  font-size: 32rpx;
  height: 80rpx;
  line-height: 80rpx;
  padding: 0 32rpx;
}

page button[size=large] {
  font-size: 32rpx;
  height: 96rpx;
  line-height: 96rpx;
  padding: 0 32rpx;
}

page button,
page .button-hover,
page button[type=default],
page .button-hover[type=default] {
  color: var(--colorGray);
  background: var(--colorGrayE);
}

page button[type=active],
page .button-hover[type=active] {
  color: var(--colorWhite);
  background: var(--colorBlue);
}

page button[type=primary],
page .button-hover[type=primary] {
  color: var(--colorWhite);
  background: var(--colorGreen);
}

page button[type=warn],
page .button-hover[type=warn] {
  color: var(--colorWhite);
  background: var(--colorYellow);
}

page button[type=error],
page .button-hover[type=error] {
  color: var(--colorWhite);
  background: var(--colorRed);
}

page button[plain],
page .button-hover[plain],
page button[type=default][plain],
page .button-hover[type=default][plain] {
  color: var(--colorGray);
  border: 1px solid var(--colorGrayD);
  background: none;
}

page button[type=active][plain],
page .button-hover[type=active][plain] {
  color: var(--colorBlue);
  border: 1px solid var(--colorBlue);
}

page button[type=primary][plain],
page .button-hover[type=primary][plain] {
  color: var(--colorGreen);
  border: 1px solid var(--colorGreen);
}

page button[type=warn][plain],
page .button-hover[type=warn][plain] {
  color: var(--colorYellow);
  border: 1px solid var(--colorYellow);
}

page button[type=error][plain],
page .button-hover[type=error][plain] {
  color: var(--colorRed);
  border: 1px solid var(--colorRed);
}

page button[disabled],
page button[disabled][type=default],
page button[disabled][type=active],
page button[disabled][type=primary],
page button[disabled][type=warn],
page button[disabled][type=error] {
  color: var(--colorWhite);
  background: var(--colorGrayD);
}