css代码段

  • item

reset 类

浏览器默认样式

  1. chrome 浏览器中,进行默认填充时 input 会填充黄色背景
1
2
3
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset !important;
}
  1. chrome placeholder 默认字体颜色
1
2
3
input::placeholder {
color: #ccc !important;
}
  1. chrome 中 search input 后面的清空图标清除
1
2
3
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none; //此处只是去掉默认的小×
}
  1. input 的默认样式
1
2
3
input {
-webkit-appearance: none;
}

布局类

  1. 页面导航 fixed 的时候,元素将会覆盖在滚动条上
1
2
3
4
5
6
7
8
:root {
overflow-x: hidden;
overflow-y: auto;
}

:root body {
position: absolute;
}

常用 reset

  1. 清除浏览器差异 normalize.css
  2. 使用程序员偏好的样式 sanitize.css
  3. 清空浏览器默认样式 reset
  4. 使用 postcss 管理 normalize 与 sanitize 的使用 postcss-normalize
  5. 自用 reset 样式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
body {
font-family: AvenirMedium, Arial, "微软雅黑";
line-height: 1.8;
margin: 0;
}
i {
font-style: normal;
}

p {
font-size: inherit;

margin: 0;
}
ul {
margin: 0;
padding: 0;
}

li {
margin: 0;
padding: 0;

list-style: none;
}

a[herf=""] {
cursor: default;
}

input {
font-size: inherit;
line-height: inherit;

box-sizing: border-box;
width: 100%;

color: inherit;
border: none;
border-radius: 0;
outline: none;

-webkit-appearance: none;
}

input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset !important;
}

input::placeholder {
color: #ccc !important;
}

input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none; //此处只是去掉默认的小×
}

input:active,
input:focus {
border: none;
outline: none;
}

img {
vertical-align: top;
max-width: 100%;

content: normal !important;
vertical-align: top;
}

a {
display: inline-block;

text-decoration: none;

color: inherit;
}
svg {
vertical-align: middle;
}
button {
outline: 0;
}
video {
vertical-align: middle;
}