Skip to content

Commit 5d02c57

Browse files
committed
finished flex panel gallery
1 parent 4354cae commit 5d02c57

File tree

2 files changed

+290
-0
lines changed

2 files changed

+290
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
display: flex;
28+
}
29+
30+
.panel {
31+
background:#6B0F9C;
32+
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
33+
color:white;
34+
text-align: center;
35+
align-items:center;
36+
/* Safari transitionend event.propertyName === flex */
37+
/* Chrome + FF transitionend event.propertyName === flex-grow */
38+
transition:
39+
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
40+
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41+
background 0.2s;
42+
font-size: 20px;
43+
background-size:cover;
44+
background-position:center;
45+
flex: 1;
46+
justify-content: center;
47+
display: flex;
48+
flex-direction: column;
49+
}
50+
51+
52+
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
53+
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
54+
.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); }
55+
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
56+
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
57+
58+
/* Flex Items */
59+
.panel > * {
60+
margin:0;
61+
width: 100%;
62+
transition:transform 0.5s;
63+
flex: 1 0 auto;
64+
display:flex;
65+
justify-content: center;
66+
align-items: center;
67+
}
68+
69+
.panel > *:first-child { transform: translateY(-100%); }
70+
.panel.open-active > *:first-child { transform: translateY(0); }
71+
.panel > *:last-child { transform: translateY(100%); }
72+
.panel.open-active > *:last-child { transform: translateY(0); }
73+
74+
.panel p {
75+
text-transform: uppercase;
76+
font-family: 'Amatic SC', cursive;
77+
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
78+
font-size: 2em;
79+
}
80+
.panel p:nth-child(2) {
81+
font-size: 4em;
82+
}
83+
84+
.panel.open {
85+
flex: 5;
86+
font-size:40px;
87+
}
88+
89+
.cta {
90+
color:white;
91+
text-decoration: none;
92+
}
93+
94+
</style>
95+
96+
97+
<div class="panels">
98+
<div class="panel panel1">
99+
<p>Hey</p>
100+
<p>Let's</p>
101+
<p>Dance</p>
102+
</div>
103+
<div class="panel panel2">
104+
<p>Give</p>
105+
<p>Take</p>
106+
<p>Receive</p>
107+
</div>
108+
<div class="panel panel3">
109+
<p>Experience</p>
110+
<p>It</p>
111+
<p>Today</p>
112+
</div>
113+
<div class="panel panel4">
114+
<p>Give</p>
115+
<p>All</p>
116+
<p>You can</p>
117+
</div>
118+
<div class="panel panel5">
119+
<p>Life</p>
120+
<p>In</p>
121+
<p>Motion</p>
122+
</div>
123+
</div>
124+
125+
<script>
126+
const panels = document.querySelectorAll('.panel');
127+
128+
function toggleOpen() {
129+
console.log('Hello');
130+
this.classList.toggle('open');
131+
}
132+
133+
function toggleActive(e) {
134+
console.log(e.propertyName);
135+
if (e.propertyName.includes('flex')) {
136+
this.classList.toggle('open-active');
137+
}
138+
}
139+
140+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
141+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
142+
</script>
143+
144+
</body>
145+
</html>

flex_panel_gallery/index.html

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
display: flex;
28+
}
29+
30+
.panel {
31+
background:#6B0F9C;
32+
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
33+
color:white;
34+
text-align: center;
35+
align-items:center;
36+
/* Safari transitionend event.propertyName === flex */
37+
/* Chrome + FF transitionend event.propertyName === flex-grow */
38+
transition:
39+
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
40+
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41+
background 0.2s;
42+
font-size: 20px;
43+
background-size:cover;
44+
background-position:center;
45+
flex: 1;
46+
justify-content: center;
47+
align-items: center;
48+
display: flex;
49+
flex-direction: column;
50+
}
51+
52+
53+
.panel1 { background-image:url(http://www.licessories.eu/upload_pic/products/828/orig_16-11-2013_12-46-48_grumpy_cat.jpg); }
54+
.panel2 { background-image:url(https://media.glamour.com/photos/56959b4d93ef4b09520d6ecb/master/pass/inspired-2015-02-condom-main.jpg); }
55+
.panel3 { background-image:url(https://lh4.googleusercontent.com/-R3WpyTjhNZk/TXbmpfIMEEI/AAAAAAAAAKM/bMzZMlP2eB0/s1600/gargling+copy.jpg); }
56+
.panel4 { background-image:url(https://img1.etsystatic.com/110/0/5795512/il_fullxfull.903544899_8duo.jpg); }
57+
.panel5 { background-image:url(http://1.bp.blogspot.com/_D9rJtdybYUQ/TSKbzkeirrI/AAAAAAAAAGs/y10-3QDlKkc/s1600/put+your+hands+up+copy.jpg); }
58+
59+
.panel > * {
60+
margin:0;
61+
width: 100%;
62+
transition:transform 0.5s;
63+
flex: 1 0 auto;
64+
display: flex;
65+
justify-content: center;
66+
align-items: center;
67+
}
68+
69+
.panel > *:first-child { transform: translateY(-100%); }
70+
.panel.open-active > *:first-child { transform: translateY(0); }
71+
.panel > *:last-child { transform: translateY(100%); }
72+
.panel.open-active > *:last-child { transform: translateY(0); }
73+
74+
.panel p {
75+
text-transform: uppercase;
76+
font-family: 'Amatic SC', cursive;
77+
text-shadow:0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45);
78+
font-size: 2em;
79+
}
80+
.panel p:nth-child(2) {
81+
font-size: 4em;
82+
}
83+
84+
.panel.open {
85+
font-size:40px;
86+
flex: 5;
87+
}
88+
89+
.cta {
90+
color:white;
91+
text-decoration: none;
92+
}
93+
94+
</style>
95+
96+
97+
<div class="panels">
98+
<div class="panel panel1">
99+
<p>oi</p>
100+
<p>wanna</p>
101+
<p>fug?</p>
102+
</div>
103+
<div class="panel panel2">
104+
<p>Give</p>
105+
<p>me</p>
106+
<p>pizza</p>
107+
</div>
108+
<div class="panel panel3">
109+
<p>Escaflowne</p>
110+
<p>Is</p>
111+
<p>Gay</p>
112+
</div>
113+
<div class="panel panel4">
114+
<p>Point</p>
115+
<p>Line</p>
116+
<p>Trrriannggle</p>
117+
</div>
118+
<div class="panel panel5">
119+
<p>Booboo</p>
120+
<p>My</p>
121+
<p>Baabaa</p>
122+
</div>
123+
</div>
124+
125+
<script>
126+
const panels = document.querySelectorAll('.panel');
127+
128+
function toggleOpen(){
129+
this.classList.toggle('open');
130+
}
131+
function toggleActive(e){
132+
console.log(e.propertyName);
133+
if (e.propertyName.includes('flex')){
134+
this.classList.toggle('open-active');
135+
}
136+
}
137+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
138+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
139+
140+
</script>
141+
142+
143+
144+
</body>
145+
</html>

0 commit comments

Comments
 (0)