File tree 6 files changed +137
-0
lines changed
6 files changed +137
-0
lines changed File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 " />
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6
+ <!-- <link
7
+ rel="stylesheet"
8
+ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
9
+ integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
10
+ crossorigin="anonymous"
11
+ /> -->
12
+ < link rel ="stylesheet " href ="style.css " />
13
+ < title > Expanding cards</ title >
14
+ </ head >
15
+ < body >
16
+ < div class ="container ">
17
+ < div
18
+ class ="panel active "
19
+ style ="
20
+ background-image: url('https://images.unsplash.com/photo-1610212570473-6015f631ae96?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
21
+ "
22
+ >
23
+ < h3 > Explore the world</ h3 >
24
+ </ div >
25
+ < div
26
+ class ="panel "
27
+ style ="
28
+ background-image: url('https://images.unsplash.com/photo-1610212570473-6015f631ae96?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
29
+ "
30
+ >
31
+ < h3 > Explore the world</ h3 >
32
+ </ div >
33
+ < div
34
+ class ="panel "
35
+ style ="
36
+ background-image: url('https://images.unsplash.com/photo-1610212570473-6015f631ae96?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
37
+ "
38
+ >
39
+ < h3 > Explore the world</ h3 >
40
+ </ div >
41
+ < div
42
+ class ="panel "
43
+ style ="
44
+ background-image: url('https://images.unsplash.com/photo-1610212570473-6015f631ae96?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
45
+ "
46
+ >
47
+ < h3 > Explore the world</ h3 >
48
+ </ div >
49
+ < div
50
+ class ="panel "
51
+ style ="
52
+ background-image: url('https://images.unsplash.com/photo-1610212570473-6015f631ae96?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
53
+ "
54
+ >
55
+ < h3 > Explore the world</ h3 >
56
+ </ div >
57
+ </ div >
58
+ < script src ="script.js "> </ script >
59
+ </ body >
60
+ </ html >
Original file line number Diff line number Diff line change
1
+ const panels = document . querySelectorAll ( ".panel" ) ;
2
+
3
+ panels . forEach ( ( panel ) => {
4
+ panel . addEventListener ( "click" , ( ) => {
5
+ removeActiveClasses ( ) ;
6
+ panel . classList . add ( "active" ) ;
7
+ } ) ;
8
+ } ) ;
9
+
10
+ const removeActiveClasses = ( ) => {
11
+ panels . forEach ( ( panel ) => {
12
+ panel . classList . remove ( "active" ) ;
13
+ } ) ;
14
+ } ;
Original file line number Diff line number Diff line change
1
+ @import url ("https://fonts.googleapis.com/css2?family=Muli&display=swap" );
2
+
3
+ * {
4
+ box-sizing : border-box; // to avoid width problems if padding
5
+ }
6
+
7
+ body {
8
+ font-family : "Muli" , sans-serif;
9
+ display : flex;
10
+ align-items : center;
11
+ justify-content : center;
12
+ height : 100vh ;
13
+ overflow : hidden; // to hide scrollbars
14
+ margin : 0 ;
15
+ }
16
+
17
+ .container {
18
+ display : flex;
19
+ width : 90vw ;
20
+ }
21
+
22
+ .panel {
23
+ background-size : auto 100% ;
24
+ background-position : center;
25
+ background-repeat : no-repeat;
26
+ height : 80vh ;
27
+ border-radius : 50px ;
28
+ color : # fff ;
29
+ cursor : pointer;
30
+ flex : 0.5 ;
31
+ margin : 10px ;
32
+ position : relative;
33
+ transition : flex 0.7s ease-in;
34
+ }
35
+
36
+ .panel h3 {
37
+ font-size : 24px ;
38
+ position : absolute;
39
+ bottom : 20px ;
40
+ left : 20px ;
41
+ margin : 0 ;
42
+ opacity : 0 ;
43
+ }
44
+
45
+ .panel .active {
46
+ flex : 5 ;
47
+ }
48
+
49
+ .panel .active h3 {
50
+ opacity : 1 ;
51
+ transition : opacity 0.3s ease-in 0.4s ;
52
+ }
53
+
54
+ @media (max-width : 480px ) {
55
+ .container {
56
+ width : 100vw ;
57
+ }
58
+
59
+ .panel : nth-of-type (4 ),
60
+ .panel : nth-of-type (5 ) {
61
+ display : none;
62
+ }
63
+ }
You can’t perform that action at this time.
0 commit comments