28
28
</ nav >
29
29
30
30
< div class ="position-relative overflow-hidden p-3 text-white header-box ">
31
- < div class ="col-md-6 p-lg-3 ml-md-5 my-3 ">
31
+ < div class ="col-md-6 p-lg-5 ml-md-5 my-3 ">
32
32
< h1 class ="display-4 font-weight-normal "> CSS Text</ h1 >
33
- < p class ="text-muted "> Challenge yourself and become a CSS expert. Be creative, submit your result and check out what others have created.
33
+ < p class ="text-muted " style =" font-size:1.2rem!important " > Challenge yourself and become a CSS expert. Be creative, submit your result and check out what others have created.
34
34
< br /> < br /> Improve your front-end skills by challenging yourself with real projects.</ p >
35
35
</ div >
36
36
</ div >
37
37
38
38
< div class ="py-5 ">
39
39
< div class ="container ">
40
40
< div class ="row ">
41
- < div class ="col-md-4 ">
41
+ < div class ="col-12 ">
42
+ < div id ="myBtnContainer ">
43
+ < button class ="btn active " onclick ="filterSelection('all') "> Show all</ button >
44
+ < button class ="btn " onclick ="filterSelection('cars') "> Cars</ button >
45
+ < button class ="btn " onclick ="filterSelection('animals') "> Animals</ button >
46
+ < button class ="btn " onclick ="filterSelection('fruits') "> Fruits</ button >
47
+ < button class ="btn " onclick ="filterSelection('colors') "> Colors</ button >
48
+ </ div >
49
+ </ div >
50
+ < div class ="col-md-4 filterDiv cars ">
42
51
< div class ="card mb-4 ">
43
52
< a href ="https://coding-dragon.github.io/css/text/effect2 " target ="_blank ">
44
53
< img class ="bd-placeholder-img card-img-top " src ="https://coding-dragon.github.io/css/text/effect2/effect2.png " width ="100% " height ="200 " />
@@ -55,7 +64,7 @@ <h3>CSS Text Effect 2</h3>
55
64
</ div >
56
65
</ div >
57
66
58
- < div class ="col-md-4 ">
67
+ < div class ="col-md-4 filterDiv colors ">
59
68
< div class ="card mb-4 ">
60
69
< a href ="https://coding-dragon.github.io/css/text/effect1 " target ="_blank ">
61
70
< img class ="bd-placeholder-img card-img-top " src ="https://coding-dragon.github.io/css/text/effect1/effect1.png " width ="100% " height ="200 " />
@@ -90,7 +99,50 @@ <h3>CSS Text Effect 1</h3>
90
99
</ p >
91
100
</ div >
92
101
</ footer >
93
-
102
+ < script >
103
+ filterSelection ( "all" )
104
+ function filterSelection ( c ) {
105
+ var x , i ;
106
+ x = document . getElementsByClassName ( "filterDiv" ) ;
107
+ if ( c == "all" ) c = "" ;
108
+ for ( i = 0 ; i < x . length ; i ++ ) {
109
+ w3RemoveClass ( x [ i ] , "show" ) ;
110
+ if ( x [ i ] . className . indexOf ( c ) > - 1 ) w3AddClass ( x [ i ] , "show" ) ;
111
+ }
112
+ }
113
+
114
+ function w3AddClass ( element , name ) {
115
+ var i , arr1 , arr2 ;
116
+ arr1 = element . className . split ( " " ) ;
117
+ arr2 = name . split ( " " ) ;
118
+ for ( i = 0 ; i < arr2 . length ; i ++ ) {
119
+ if ( arr1 . indexOf ( arr2 [ i ] ) == - 1 ) { element . className += " " + arr2 [ i ] ; }
120
+ }
121
+ }
122
+
123
+ function w3RemoveClass ( element , name ) {
124
+ var i , arr1 , arr2 ;
125
+ arr1 = element . className . split ( " " ) ;
126
+ arr2 = name . split ( " " ) ;
127
+ for ( i = 0 ; i < arr2 . length ; i ++ ) {
128
+ while ( arr1 . indexOf ( arr2 [ i ] ) > - 1 ) {
129
+ arr1 . splice ( arr1 . indexOf ( arr2 [ i ] ) , 1 ) ;
130
+ }
131
+ }
132
+ element . className = arr1 . join ( " " ) ;
133
+ }
134
+
135
+ // Add active class to the current button (highlight it)
136
+ var btnContainer = document . getElementById ( "myBtnContainer" ) ;
137
+ var btns = btnContainer . getElementsByClassName ( "btn" ) ;
138
+ for ( var i = 0 ; i < btns . length ; i ++ ) {
139
+ btns [ i ] . addEventListener ( "click" , function ( ) {
140
+ var current = document . getElementsByClassName ( "active" ) ;
141
+ current [ 0 ] . className = current [ 0 ] . className . replace ( " active" , "" ) ;
142
+ this . className += " active" ;
143
+ } ) ;
144
+ }
145
+ </ script >
94
146
< script src ="https://code.jquery.com/jquery-3.5.1.slim.min.js " integrity ="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj " crossorigin ="anonymous "> </ script >
95
147
< script > window . jQuery || document . write ( '<script src="https://getbootstrap.com/docs/4.5/assets/js/vendor/jquery.slim.min.js"><\/script>' ) </ script > < script src ="https://getbootstrap.com/docs/4.5/dist/js/bootstrap.bundle.min.js " integrity ="sha384-1CmrxMRARb6aLqgBO7yyAxTOQE2AKb9GfXnEo760AUcUmFx3ibVJJAzGytlQcNXd " crossorigin ="anonymous "> </ script > </ body >
96
148
</ html >
0 commit comments