LoginSignup
3
1

More than 5 years have passed since last update.

RailsでbootstrapのHome画面サムネイルPartial

Last updated at Posted at 2017-09-08

前回のRailsでBootstrapのスライドショーPartialに引き続き、サムネイルも作ってみたのでメモ。
アイコン画像はicooon-monoの64pxを使用。

スクリーンショット 2017-09-08 14.38.07.png

home.html.erb
<%= render 'home_thumbnail', thumbnails: [ { title: 'いつでも', image: 'clock.png', caption: 'いつでも' },
  { title: 'どこでも', image: 'place.png', caption: 'どこでも' }, 
  { title: '全員で', image: 'meeting.png', caption: '全員で' } ] %>

3つなので幅は4を指定

_home_thumbnail.html.erb
<div class="container">
    <div class="row">
        <% thumbnails.each do |t| %>
            <div class="col-md-4">
                <div class="thumbnail">
                    <%= image_tag(t[:image], :alt => t[:image]) %>
                    <div class="caption">
                        <h3><%= t[:title] %></h3>
                        <p><%= t[:caption] %></p>
                    </div>
                </div>
            </div>
        <% end %>
    </div>
</div>
home.scss
.thumbnail{
  .caption {
    text-align: center;
  }
}
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1