"Sort Elements with Flexbox (Pure CSS)"
Bootstrap 4.1.1 Snippet by koshikojha

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
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="products">
<input class="sort-radio" type="radio" name="sort-radio" id="app"/>
<input class="sort-radio" type="radio" name="sort-radio" id="game"/>
<input class="sort-radio" type="radio" name="sort-radio" id="service"/>
<div class="products__sort">
<label class="button" for="app">app</label>
<label class="button" for="game">game</label>
<label class="button" for="service">service</label>
</div>
<div class="products__wrap">
<div class="product" data-product-type="app">app</div>
<div class="product" data-product-type="app">app</div>
<div class="product" data-product-type="game">game</div>
<div class="product" data-product-type="service">service</div>
<div class="product" data-product-type="game">game</div>
<div class="product" data-product-type="service">service</div>
<div class="product" data-product-type="app">app</div>
<div class="product" data-product-type="game">game</div>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
@import url("https://fonts.googleapis.com/css?family=Quicksand:700");
body {
padding: 62px;
background: #F5F5F5;
}
body * {
font-family: "Quicksand", sans-serif;
}
.products__sort {
display: flex;
flex-flow: wrap;
}
.products__sort .button {
padding: 12px 24px;
margin: 0 12px 12px 0;
border: none;
border-radius: 6px;
background-color: #00BCD4;
color: #fff;
cursor: pointer;
}
.products__sort .button:hover {
background-color: #007888;
}
.products__wrap {
display: flex;
flex-flow: wrap;
margin: 48px 0 0;
}
.products__wrap .product {
height: 112px;
width: 112px;
padding: 16px 32px;
margin: 0 16px 16px 0;
border: none;
border-radius: 6px;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: