WEBデザインの勉強

初心者が1からWEBデザインを勉強するブログ。

ブロックを隙間なく並べるjQueryプラグインMasonry

absoluteで位置を配置してくれる。
可変グリッドに対応

masonry.desandro.com

github.com


デモはこちら
http://efu.sakura.ne.jp/web/masonry/

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>Masonry</title>
  <link href="https://fonts.googleapis.com/css?family=Asul:400,700" rel="stylesheet">
  <link rel="stylesheet" href="css/style.css">
  <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script src="js/imagesloaded.pkgd.js"></script>
  <script src="js/masonry.pkgd.min.js"></script>
  <script>
    $(function(){
      var $container = $('.list');
      $container.imagesLoaded(function(){
        $container.masonry({
          itemSelector: 'li',
          columnWidth: 200,
          gutter: 20,
        });
      });
    });
  </script>
</head>
<body>
  <div class="content">
    <ul class="list">
      <li class="box01">
        <p>BOX1</p>
      </li>
      <li class="box02">
        <p>BOX2</p>
      </li>
      <li class="box03">
        <p>BOX3</p>
      </li>
      <li class="box01">
        <p>BOX4</p>
      </li>
      <li class="box02">
        <p>BOX5</p>
      </li>
      <li class="box03">
        <p>BOX6</p>
      </li>
      <li class="box01">
        <p>BOX7</p>
      </li>
      <li class="box02">
        <p>BOX8</p>
      </li>
      <li class="box03">
        <p>BOX9</p>
      </li>
      <li class="box01">
        <p>BOX10</p>
      </li>
    </ul>
  </div>
</body>
</html>
@charset "utf-8";

/* http://meyerweb.com/eric/tools/css/reset/
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

.content {
  width: 640px;
  margin: 50px auto;
}

.list li {
  width: 200px;
  margin-bottom: 20px;
  border-radius: 20px;
}


.list li p {
  margin-top: 40px;
  text-align: center;
  font-family: 'Asul', sans-serif;
  font-weight: bold;
  font-size: 24px;
  color: #3C3B5C;
  letter-spacing: 0.08em;
}

.list .box01 {
  height: 300px;
  background: #FFCFDF;
}

.list .box02 {
  height: 500px;
  background: #E0F9B5
}

.list .box03 {
  height: 250px;
  background: #A5DEE5
}