-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
108 lines (108 loc) · 3.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Cardfilter with CSS</title>
<!-- Custom CSS -->
<style>
button.active {
font-weight: bold;
}
.filter {
float:left;
margin: 0 10px 10px 0;
padding: 20px 20px 30px;
border:solid #000 1px;
}
.red {
background-color: red;
}
.yellow {
background-color: yellow;
}
.green {
background-color: green;
}
a.change {
position: absolute;
top: 10px;
right: 10px;
}
</style>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Custom JS -->
<script>
$(document).ready(function() {
$(".btn-filter").click(function() {
var value = $(this).attr('data-filter');
if(value == "all") {
$('.filter').show('1000');
} else {
$(".filter").not('.'+value).hide('3000');
$('.filter').filter('.'+value).show('3000');
}
$(".btn-filter").removeClass('active');
$(this).addClass('active');
});
});
</script>
</head>
<body>
<h1>Filter Cards</h1>
<h2>With CSS</h2>
<a href="./index-bootstrap.html" class="change">With Bootstrap</a>
<button class="btn-filter active" data-filter="all">All Cards</button>
<button class="btn-filter" data-filter="red">Red Cards</button>
<button class="btn-filter" data-filter="yellow">Yellow Cards</button>
<button class="btn-filter" data-filter="green">Green Cards</button>
<hr />
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
<div class="filter red">Red Card</div>
<div class="filter yellow">Yellow Card</div>
<div class="filter green">Green Card</div>
</body>
</html>