![イメージ説明]WIDTH:600
Masonryを使用し画像を一覧表示しています。ヘッダーのサイズに合わせて画像を一覧表示させたいのですが、画像のように両サイドが余ってしまいます。
どのようにすればヘッダーにぴったり合わせることができるでしょうか
lang
1* { 2 margin: 0; 3 padding: 0; 4 -webkit-box-sizing: border-box; 5 -moz-box-sizing: border-box; 6 box-sizing: border-box; 7 8} 9 10.pinGridWrapper h1 { 11 font-size: 2.0em; 12 padding: 10px 0 10px 0; 13 text-align: center; 14 max-width: 160em; 15 margin: 0 auto; 16} 17.pinGrid { 18 width: 103.125%; 19 overflow: hidden; 20 margin-left: -1.562%; 21 margin-bottom: -1.875em; 22} 23.pin { 24 display: inline-block; 25 background: #fff; 26 border-radius: 4px; 27 -webkit-box-shadow: 0 6px 6px -6px #ccc; 28 -moz-box-shadow: 0 6px 6px -6px #ccc; 29 -webkit-column-break-inside: avoid; 30 -moz-column-break-inside: avoid; 31 column-break-inside: avoid; 32 33 max-width: 100%; 34 box-shadow: 0.5px 0.5px 0.5px 0 #8b8b8b; 35 36 37 width: 30.303%; 38 float: left; 39 margin: 0 1.515% 1.875em; 40} 41.pin img { 42 width: 100%; 43 height: auto; 44 -webkit-border-radius: 10px 10px 0 0; 45 -moz-border-radius: 10px 10px 0 0; 46 border-radius: 4px 4px 0 0; 47} 48 49 50@media only screen and ( max-width: 160em ) 51{ 52 .pin 53 { 54 width: 23.088%; 55 margin-bottom: 0.938em; 56 margin-right: 0; 57 } 58} 59@media only screen and ( max-width: 70em ) 60{ 61 .pin 62 { 63 width: 31.280%; 64 margin-bottom: 0.938em; 65 margin-right: 0; 66 } 67} 68@media only screen and ( max-width: 40em ) 69{ 70 .pin 71 { 72 width: 47.786%; 73 margin-bottom: 0.938em; 74 } 75} 76@media only screen and ( max-width: 15em ) 77{ 78 .pin 79 { 80 width: 100%; 81 margin-left: 0; 82 margin-right: 0; 83 } 84} 85 86 87 88
lang
1//masonry.js 2$(document).on('ready page:change ', function() { 3 var $container = $('.pinGridWrapper'); 4 5 $container.imagesLoaded(function() { 6 $container.masonry({ 7 itemSelector: '.pin', 8 isFitWidth: true, 9 reload: true, 10 isAnimated: true, 11 12 animationOptions: { 13 duration: 200, 14 easing: 'swing' 15 } 16 }); 17 18 }); 19 $(function($) { 20 $('pin').hide(); 21 $('pin').each(function(i) { 22 $(this).delay(i * 2).fadeIn(80);//デフォルト1000 23 }); 24 }); 25});
html.erb
lang
1<div class="pinGridWrapper"> 2 <div class="pinGrid"> 3 <% @items.each do |item| %><!-- アイテムインデックス start--> 4 <div class="pin"> 5 <% if item.picture_1.present? %> 6 <%= link_to(item) { image_tag item.picture_1_url(:thumb),:class =>"index_border_radius" } %> 7 8 <% unless item.infraction %> 9 <h2 class="palette-paragraph"> 10 <%= item.title %> 11 </h2> 12 <% else %> 13 <h4 class="palette-paragraph"> 14 違反アイテム 15 </h4> 16 <% end %> 17 18 19 <p><small><small> 20 <i class="fa fa-clock-o"></i> 21 <span class="countdown" data-until= "<%= item.limit_day.to_datetime %>" ></span> 22 </small></small></p> 23 <% else %> 24 <%= link_to(item) {image_tag("opps.jpg", :size => '135x135') } %> 25 <% end %> 26 </div> 27 <% end %><!-- アイテムインデックス end --> 28 </div> 29</div> 30 31 32<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center"> 33 <div class="form-group"> 34 <div class="pagination"> 35 <%= paginate @items %> 36 </div> 37 </div> 38</div> 39
生成されるHTML
lang
1<div class="pinGridWrapper"> 2 <div class="pinGrid"> 3 <% @items.each do |item| %><!-- アイテムインデックス start--> 4 <div class="pin"> 5 <% if item.picture_1.present? %> 6 <%= link_to(item) { image_tag item.picture_1_url(:thumb),:class =>"index_border_radius" } %> 7 8 <% unless item.infraction %> 9 <h2 class="palette-paragraph"> 10 <%= item.title %> 11 </h2> 12 <% else %> 13 <h4 class="palette-paragraph"> 14 違反アイテム 15 </h4> 16 <% end %> 17 18 19 <p><small><small> 20 <i class="fa fa-clock-o"></i> 21 <span class="countdown" data-until= "<%= item.limit_day.to_datetime %>" ></span> 22 </small></small></p> 23 <% else %> 24 <%= link_to(item) {image_tag("opps.jpg", :size => '135x135') } %> 25 <% end %> 26 </div> 27 <% end %><!-- アイテムインデックス end --> 28 </div> 29</div> 30 31 32<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center"> 33 <div class="form-group"> 34 <div class="pagination"> 35 <%= paginate @items %> 36 </div> 37 </div> 38</div>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/06/27 16:29
2015/06/27 23:26
退会済みユーザー
2015/06/28 06:20
2015/06/28 08:46
退会済みユーザー
2015/06/28 11:14
2015/06/28 11:20