Demo 实现代码: 页面 CSS 样式
1* {
2 margin: 0;
3 padding: 0;
4}
5
6html,
7body {
8 width: 100%;
9 height: 100%;
10}
11
12html {
13 /* 灰色模式 */
14 /* -webkit-filter: grayscale(1);
15 filter: grayscale(1); */
16}
17
18#app {
19 width: 100vw;
20 height: 100vh;
21}
22
23#app h1 {
24 line-height: 100px;
25 font-size: 40px;
26 font-weight: bold;
27 text-align: center;
28}
29
30h2 {
31 line-height: 100px;
32 font-size: 30px;
33 font-weight: bold;
34 text-align: center;
35}
36
37h2.r {
38 background: red;
39}
40
41h2.g {
42 background: green;
43}
44
45img {
46 width: 375px;
47 height: 200px;
48}
页面布局
1<!DOCTYPE html>
2<html lang="zh">
3 <head>
4 <meta charset="UTF-8" />
5 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6 <meta http-equiv="X-UA-Compatible" content="ie=edge" />
7 </head>
8 <body>
9 <div id="app">
10 <h1>Filder</h1>
11 <br />
12 <h2 class="r">红色 - RED</h2>
13 <br />
14 <img
15 src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1586019993398&di=2e9ec900359cb1a24c6c5ec131ae87f2&imgtype=0&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D4048520830%2C957432571%26fm%3D214%26gp%3D0.jpg"
16 draggable="false"
17 />
18 <br />
19 <br />
20 <h2 class="g">绿色 - GREEN</h2>
21 </div>
22 </body>
23</html>
1html {
2 /* 灰色模式 */
3 -webkit-filter: grayscale(100%);
4 filter: grayscale(100%);
5 filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
6}
主要用到的就是 CSS3 样式的 filter(滤镜)属性