Skip to content

Commit dea228b

Browse files
author
yuri12138
committed
第五天
1 parent b35ae98 commit dea228b

1 file changed

Lines changed: 149 additions & 0 deletions

File tree

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Flex Panels 💪</title>
6+
<link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'>
7+
</head>
8+
<body>
9+
<style>
10+
html {
11+
box-sizing: border-box;
12+
background:#ffc600;
13+
font-family:'helvetica neue';
14+
font-size: 20px;
15+
font-weight: 200;
16+
}
17+
body {
18+
margin: 0;
19+
}
20+
*, *:before, *:after {
21+
box-sizing: inherit;
22+
}
23+
24+
.panels {
25+
min-height:100vh;
26+
overflow: hidden;
27+
}
28+
29+
.panel {
30+
background:#6B0F9C;
31+
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
32+
color:white;
33+
text-align: center;
34+
align-items:center;
35+
/* Safari transitionend event.propertyName === flex */
36+
/* Chrome + FF transitionend event.propertyName === flex-grow */
37+
transition:
38+
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
39+
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
40+
background 0.2s;
41+
font-size: 20px;
42+
background-size:cover;
43+
background-position:center;
44+
}
45+
46+
47+
.panel>p:first-child { transform: translateY(-100%); }
48+
.panel.open-active>*:first-child { transform: translateY(0); }
49+
.panel>p:last-child { transform: translateY(-100%); }
50+
.panel.open-active>*:last-child { transform: translateY(-100%); }
51+
52+
53+
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
54+
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
55+
.panel3 { background-image:url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); }
56+
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
57+
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
58+
59+
.panel > * {
60+
margin:0;
61+
width: 100%;
62+
transition:transform 0.5s;
63+
}
64+
65+
.panel p {
66+
text-transform: uppercase;
67+
font-family: 'Amatic SC', cursive;
68+
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
69+
font-size: 2em;
70+
}
71+
.panel p:nth-child(2) {
72+
font-size: 4em;
73+
}
74+
75+
.panel.open {
76+
font-size:40px;
77+
}
78+
79+
.cta {
80+
color:white;
81+
text-decoration: none;
82+
}
83+
84+
</style>
85+
86+
87+
<div class="panels">
88+
<div class="panel panel1">
89+
<p>Hey</p>
90+
<p>Let's</p>
91+
<p>Dance</p>
92+
</div>
93+
<div class="panel panel2">
94+
<p>Give</p>
95+
<p>Take</p>
96+
<p>Receive</p>
97+
</div>
98+
<div class="panel panel3">
99+
<p>Experience</p>
100+
<p>It</p>
101+
<p>Today</p>
102+
</div>
103+
<div class="panel panel4">
104+
<p>Give</p>
105+
<p>All</p>
106+
<p>You can</p>
107+
</div>
108+
<div class="panel panel5">
109+
<p>Life</p>
110+
<p>In</p>
111+
<p>Motion</p>
112+
</div>
113+
</div>
114+
115+
<script>
116+
117+
const el = document.querySelectorAll(".panel");
118+
const elList = Array.from(el);
119+
120+
121+
function clickHandle(){
122+
//toggle():
123+
// exsit add$$return true
124+
// doesn't exsit remove&&return false
125+
this.classList.toggle('open');
126+
}
127+
128+
function transitionHandle(e){
129+
e.classList.toggle('open-active');
130+
}
131+
132+
elList.map( element => {
133+
element.addEventListener("click",clickHandle);
134+
element.addEventListener("transitionend",transitionHandle);
135+
})
136+
137+
138+
139+
140+
141+
</script>
142+
143+
144+
145+
146+
147+
148+
</body>
149+
</html>

0 commit comments

Comments
 (0)