Skip to content

Commit e742fc2

Browse files
committed
Add new examples
1 parent 99eeb39 commit e742fc2

File tree

9 files changed

+907
-212
lines changed

9 files changed

+907
-212
lines changed

43-css-gradient-shadow/index.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>CSS 渐变阴影</title>
8+
<style>
9+
* {
10+
margin: 0;
11+
padding: 0;
12+
font-family: sans-serif;
13+
box-sizing: border-box;
14+
}
15+
16+
body {
17+
background: hsl(0deg, 0%, 8%);
18+
}
19+
20+
main {
21+
width: 100vw;
22+
height: 100vh;
23+
max-width: 100%;
24+
display: grid;
25+
place-items: center;
26+
}
27+
28+
.box {
29+
width: 350px;
30+
height: 500px;
31+
background: hsl(0deg, 0%, 8%);
32+
border-radius: 8px;
33+
position: relative;
34+
}
35+
36+
.box::before {
37+
content: "";
38+
position: absolute;
39+
top: 0;
40+
left: 0;
41+
width: 100%;
42+
height: 100%;
43+
background: linear-gradient(
44+
45deg,
45+
hsl(300deg, 100%, 50%),
46+
hsl(200deg, 100%, 50%),
47+
hsl(100deg, 100%, 50%)
48+
);
49+
border-radius: 8px;
50+
filter: blur(24px);
51+
z-index: -1;
52+
}
53+
</style>
54+
</head>
55+
<body>
56+
<main>
57+
<div class="box"></div>
58+
</main>
59+
</body>
60+
</html>
3.35 MB
Loading

44-css-pointer-events/index.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>CSS Pointer Events</title>
8+
<style>
9+
* {
10+
margin: 0;
11+
padding: 0;
12+
font-family: sans-serif;
13+
box-sizing: border-box;
14+
}
15+
16+
body {
17+
background: hsl(0deg, 0%, 8%);
18+
}
19+
20+
main {
21+
width: 100vw;
22+
height: 100vh;
23+
max-width: 100%;
24+
display: grid;
25+
place-items: center;
26+
}
27+
28+
.imageContainer {
29+
position: relative;
30+
}
31+
32+
img {
33+
width: 50vw;
34+
height: auto;
35+
}
36+
37+
.overlay {
38+
position: absolute;
39+
bottom: 0;
40+
background-color: hsl(0deg, 0%, 0%, 0.8);
41+
width: 100%;
42+
padding: 48px 24px;
43+
color: white;
44+
45+
/* 可以直接点进去 */
46+
pointer-events: none;
47+
}
48+
</style>
49+
</head>
50+
<body>
51+
<main>
52+
<div class="imageContainer">
53+
<a href="https://www.zxuqian.cn">
54+
<img src="./2021-12-20-19-52-11.png" alt="" />
55+
</a>
56+
<div class="overlay">这是一段描述文案</div>
57+
</div>
58+
</main>
59+
</body>
60+
</html>

45-URLSearchParams/index.html

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>URLSearchParams</title>
8+
9+
<style>
10+
* {
11+
margin: 0;
12+
padding: 0;
13+
font-family: sans-serif;
14+
box-sizing: border-box;
15+
}
16+
17+
body {
18+
background: hsl(0deg, 0%, 8%);
19+
}
20+
21+
main {
22+
width: 100vw;
23+
height: 100vh;
24+
max-width: 100%;
25+
display: grid;
26+
place-items: center;
27+
}
28+
29+
input {
30+
border: 1px solid hsl(140deg, 100%, 50%);
31+
padding: 24px 18px;
32+
font-size: 24px;
33+
border-radius: 12px;
34+
background-color: transparent;
35+
color: white;
36+
outline: none;
37+
width: 80vw;
38+
}
39+
</style>
40+
</head>
41+
<body>
42+
<main>
43+
<div class="inputContainer">
44+
<input
45+
id="url"
46+
type="text"
47+
value='q=测试&order=asc&filters=["前端","后端"]'
48+
/>
49+
</div>
50+
</main>
51+
<script>
52+
const urlInput = document.getElementById("url");
53+
const url = urlInput.value;
54+
55+
// 获取实例
56+
const params = new URLSearchParams(url);
57+
58+
// 遍历
59+
for (let p of params) {
60+
console.log(p);
61+
}
62+
63+
// 获取单个参数
64+
const keyword = params.get("q");
65+
console.log(keyword);
66+
67+
// 判断是否存在
68+
const hasOrder = params.has("order");
69+
console.log(hasOrder);
70+
71+
// 转换为字符串
72+
console.log(params.toString());
73+
74+
// 转换数组
75+
const filters = params.get("filters");
76+
console.log(JSON.parse(filters));
77+
78+
// 修改参数
79+
params.set("order", "desc");
80+
console.log(params.toString());
81+
82+
// 添加参数
83+
params.append("pageSize", "10");
84+
console.log(params.toString());
85+
86+
// 删除参数
87+
params.delete("filters");
88+
console.log(params.toString());
89+
</script>
90+
</body>
91+
</html>
1.48 MB
Loading

46-css-aspect-ratio/index.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>CSS aspect ratio</title>
8+
9+
<style>
10+
* {
11+
margin: 0;
12+
padding: 0;
13+
font-family: sans-serif;
14+
box-sizing: border-box;
15+
}
16+
17+
body {
18+
background: hsl(0deg, 0%, 8%);
19+
}
20+
21+
main {
22+
width: 100vw;
23+
height: 100vh;
24+
max-width: 100%;
25+
display: grid;
26+
place-items: center;
27+
}
28+
29+
.imageContainer {
30+
width: 500px;
31+
height: 500px;
32+
resize: both;
33+
overflow: auto;
34+
35+
/* aspect-ratio: 16 / 9; */
36+
37+
border: 4px solid hsl(140deg, 100%, 70%);
38+
}
39+
40+
img {
41+
max-width: 100%;
42+
max-height: 100%;
43+
/* 不加就是原始纵横比 */
44+
/* aspect-ratio: 1 / 1; */
45+
}
46+
</style>
47+
</head>
48+
<body>
49+
<main>
50+
<div class="imageContainer">
51+
<img src="./2021-12-20-20-29-28.png" alt="" />
52+
</div>
53+
</main>
54+
</body>
55+
</html>

0 commit comments

Comments
 (0)