WEBサイト制作の勉強

WEBサイト制作の勉強の為の解説ブログです。

フェリカテクニカルアカデミー

フィルター機能とソート機能がついた「MixItUp」

ある程度の数のサムネイルを見せる時にはフィルタリング機能やソート機能を使い、グループ分けしてあげる事がサイトの見易さにつながります。



f:id:yachin29:20160204200022p:plain



mixitup.kunkalabs.com

<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>MixItUp</title>
<link href="style.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery.mixitup/latest/jquery.mixitup.min.js"></script>
<script>
    // On document ready:
$(function(){
	// Instantiate MixItUp:
	$('#Container').mixItUp();
});
</script>
</head>
<body>
<div class="controls">
  <label>カテゴリー:</label>
  <button class="filter" data-filter="all">全部</button>
  <button class="filter" data-filter=".category-1">赤いもの</button>
  <button class="filter" data-filter=".category-2">緑のもの</button>
  <button class="filter" data-filter=".category-3">黄色いもの</button>
  <button class="filter" data-filter=".category-4">くだもの</button>
  <label>Sort:</label>
  <button class="sort" data-sort="myorder:asc">番号の小さい順</button>
  <button class="sort" data-sort="myorder:desc">番号の大きい順</button>
</div>
<div id="Container" class="container">
  <div class="mix category-1" data-myorder="1"><a href="#"><img src="img/01.jpg"></a></div>
  <div class="mix category-1" data-myorder="2"><a href="#"><img src="img/02.jpg"></a></div>
  <div class="mix category-1 category-4" data-myorder="3"><a href="#"><img src="img/03.jpg"></a></div>
  <div class="mix category-2" data-myorder="4"><a href="#"><img src="img/04.jpg"></a></div>
  <div class="mix category-2 category-4" data-myorder="5"><a href="#"><img src="img/05.jpg"></a></div>
  <div class="mix category-2" data-myorder="6"><a href="#"><img src="img/06.jpg"></a></div>
  <div class="mix category-3 category-4" data-myorder="7"><a href="#"><img src="img/07.jpg"></a></div>
  <div class="mix category-3" data-myorder="8"><a href="#"><img src="img/08.jpg"></a></div>
  <div class="mix category-3" data-myorder="9"><a href="#"><img src="img/09.jpg"></a></div>
  <div class="gap"></div>
  <div class="gap"></div>
</div>
</div>
</body>
</html>
@charset "utf-8";
/* CSS Document */

/* reset */
html, body, div, h1, h2, h3, h4, h5, h6,p, blockquote, pre, 
address,ul, ol, li, dl, dt, dd,table, th, td, form, fieldset {
  margin: 0;
  padding: 0;
  line-height: 1.0;
  font-family:
    "Hiragino Kaku Gothic ProN",
    Meiryo, 
    sans-serif;
  box-sizing: border-box;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
ul, ol {
  list-style: none; /* マーカーを消す */
}
a {
  text-decoration: none; /* 下線を消す */
}
img {
  border: 0;
  vertical-align: bottom;
}

/*body {
	overflow-y: scroll;
}*/
.controls{
  padding: 2%;
  background: #333;
  color: #eee;
}

label{
  font-weight: 300;
  margin: 0 .4em 0 0;
}

button{
  display: inline-block;
  padding: .4em .8em;
  background: #666;
  border: 0;
  color: #ddd;
  font-size: 16px;
  font-weight: 300;
  border-radius: 4px;
  cursor: pointer;
}

button.active{
  background: #68b8c4;
}

button:focus{
  outline: 0 none;
}

button + label{
  margin-left: 1em;
}

.container{
  padding: 2% 2% 0;
  text-align: justify;
  font-size: 0.1px;
  background: #68b8c4;
  -webkit-backface-visibility: hidden;
}

.container:after{
  content: '';
  display: inline-block;
  width: 100%;
}

.container .mix,
.container .gap{
  display: inline-block;
  width: 49%;
}

.container .mix{
  background: #03899c;
  margin-bottom: 2%;
  display: none;
}

.container .mix:after{
 /* content: attr(data-myorder);*/
  color: white;
  font-size: 16px;
  display: inline-block;
  vertical-align: top;
  /*padding: 4% 0 6% 0;*/
  font-weight: 700;
}

.container .mix:before{
  content: '';
  display: inline-block;
  padding-top: 60%;
}
img {
  max-width: 100%;
}
@media all and (min-width: 420px){
  .container .mix,
  .container .gap{
    width: 32%;
  }
}

@media all and (min-width: 640px){
  .container .mix,
  .container .gap{
    width: 24%;
  }
}