0
0

More than 1 year has passed since last update.

【tableタグ】サイズ調整

Last updated at Posted at 2023-03-25

tableタグ サイズ調整したい

下記のように書くと、画面いっぱいに表示されてしまう…
中心にまとめたいなぁ、、、

<h2>投稿一覧</h2>

      <table class="table">
        <thead>
          <th>画像</th>
          <th>タイトル</th>
          <th>カテゴリー</th>
          <th></th>
          <th>本文</th>
        </thead>
        <tbody>
          <% @spots.each do |spot| %>
        <tr>
          <td><%= image_tag spot.image, size: '150x100'%></td>
          <td><%= spot.name %></td>
          <td><%#= spot.category.try(:name) %></td>
          <td><%= spot.quality %></td>
          <td><%= spot.introduction %></td>
        </tr>
          <% end %>
        </tbody>
      </table>

image.png

ということで調べていきました!

<h2>投稿一覧</h2>
-------ここから-------
<div class="container text-center">
  <div class="row">
    <div class="col-md-12">
-------ここを追加--------
      <table class="table">
        <thead>
          <th>画像</th>
          <th>タイトル</th>
          <th>カテゴリー</th>
          <th></th>
          <th>本文</th>
        </thead>
        <tbody>
          <% @spots.each do |spot| %>
        <tr>
          <td><%= image_tag spot.image, size: '150x100'%></td>
          <td><%= spot.name %></td>
          <td><%#= spot.category.try(:name) %></td>
          <td><%= spot.quality %></td>
          <td><%= spot.introduction %></td>
        </tr>
          <% end %>
        </tbody>
      </table>
----これも追加-----
    </div>
  </div>
</div>
-----ここまで追加-----

image.png

こんな感じに中心にコンパクトに表示されました★

0
0
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
0
0