File tree Expand file tree Collapse file tree 3 files changed +110
-0
lines changed
Expand file tree Collapse file tree 3 files changed +110
-0
lines changed 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+ < title > Expanding Cards</ title >
7+ < link rel ="stylesheet " href ="style.css ">
8+ < header >
9+ < h1 > Famous Food in India</ h1 >
10+ </ header >
11+ </ head >
12+ < body >
13+
14+ < div class ="container ">
15+ < div class ="panel active " style ="background-image: url('https://www.indianhealthyrecipes.com/wp-content/uploads/2022/02/gobi-manchurian.jpg.webp'); ">
16+ < h3 > gobi manchurian</ h3 > </ div >
17+ < div class ="panel " style ="background-image: url('https://www.indianhealthyrecipes.com/wp-content/uploads/2021/12/tandoori-chicken-1024x1536.jpg.webp'); ">
18+ < h3 > tandoori chicken</ h3 >
19+ </ div >
20+ < div class ="panel " style ="background-image: url('https://www.indianhealthyrecipes.com/wp-content/uploads/2021/12/chicken-biryani.jpg.webp'); ">
21+ < h3 > chicken biryani</ h3 >
22+ </ div >
23+ < div class ="panel " style ="background-image: url('https://www.indianhealthyrecipes.com/wp-content/uploads/2023/05/chicken-shawarma.jpg.webp'); ">
24+ < h3 > shawarma</ h3 >
25+ </ div >
26+ < div class ="panel " style ="background-image: url('https://1.bp.blogspot.com/-pEUFitqs6Rk/YMikRdhUagI/AAAAAAABk3Y/iwZmg_bJcTkHESDGo9vw_-xrsDgS7i5WgCLcBGAsYHQ/s1244/Polish_20210614_102108696.jpg'); ">
27+ < h3 > Papdi Chaat</ h3 >
28+ </ div >
29+ </ div >
30+
31+
32+
33+
34+ < script src ="script.js "> </ script >
35+ </ body >
36+ </ html >
Original file line number Diff line number Diff line change 1+ const panels = document . querySelectorAll ( ".panel" ) ;
2+ panels . forEach ( ( panel ) => {
3+ panel . addEventListener ( "click" , ( ) => {
4+ removeActiveClasses ( ) ;
5+ panel . classList . add ( "active" ) ;
6+ } ) ;
7+ } ) ;
8+
9+ const removeActiveClasses = ( ) => {
10+ panels . forEach ( ( panel ) => {
11+ panel . classList . remove ( "active" ) ;
12+ } ) ;
13+ } ;
Original file line number Diff line number Diff line change 1+ * {
2+ box-sizing : border-box;
3+ }
4+
5+ body {
6+ font-family : sans-serif;
7+ margin : 0 ;
8+ overflow : hidden;
9+ height : 100vh ;
10+ }
11+
12+ h1 , .container {
13+ display : flex;
14+ justify-content : center;
15+ }
16+
17+ .container {
18+ align-items : center;
19+ width : 90vw ;
20+ margin : auto;
21+ }
22+ .panel {
23+ background-size : auto 100% ;
24+ background-repeat : no-repeat;
25+ background-position : center;
26+ height : 80vh ;
27+ border-radius : 50px ;
28+ color : # 494747 ;
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 : 25px ;
40+ left : 10vh ;
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+ @media (max-width : 480px ){
54+ .container {
55+ width : 100vw ;
56+ }
57+ .panel : nth-of-type (4 ),
58+ .panel : nth-of-type (5 ){
59+ display : none;
60+ }
61+ }
You can’t perform that action at this time.
0 commit comments