質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1621閲覧

画像を左端に寄せたい

tetsuya7724

総合スコア67

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2020/04/23 03:35

前提・実現したいこと

rails6のAction textを試しています。
画像を投稿したが中央寄せになっている。

発生している問題・エラーメッセージ

イメージ説明

該当のソースコード

<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>"> <% if blob.representable? %> <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 600, 400 ] : [ 520, 400 ]) %> <% end %> <figcaption class="attachment__caption"> <% if caption = blob.try(:caption) %> <%= caption %> <% else %> <!-- <span class="attachment__name"><%= blob.filename %></span> <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span> --> <% end %> </figcaption> </figure>
<p id="notice"><%= notice %></p> <h1>Articles</h1> <table> <!-- <thead> <tr> <th>Title</th> <th>Content</th> <th colspan="3"></th> </tr> </thead> --> <tbody> <% @articles.each do |article| %> <div class=main-body> <div>タイトル:</div> <div><%= article.title %></div><br> <div>内容:</div> <div><%= article.content %></div><br> <div><%= link_to 'Show', article %></div> <div><%= link_to 'Edit', edit_article_path(article) %></div> <div><%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %></div> </div> <% end %> </tbody> </table> <br> <%= link_to 'New Article', new_article_path %>

css

1body { 2 background-color: #e6eaff; 3 color: #333; 4 margin: 33px; } 5 6body, p, ol, ul, td { 7 font-family: verdana, arial, helvetica, sans-serif; 8 font-size: 13px; 9 line-height: 18px; } 10 11pre { 12 background-color: #eee; 13 padding: 10px; 14 font-size: 11px; } 15 16a { 17 color: #000; } 18 19a:visited { 20 color: #666; } 21 22a:hover { 23 color: #fff; 24 background-color: #000; } 25 26th { 27 padding-bottom: 5px; } 28 29td { 30 padding: 0 5px 7px; } 31 32div.field, 33div.actions { 34 margin-bottom: 10px; } 35 36#notice { 37 color: green; } 38 39.field_with_errors { 40 padding: 2px; 41 background-color: red; 42 display: table; } 43 44#error_explanation { 45 width: 450px; 46 border: 2px solid red; 47 padding: 7px 7px 0; 48 margin-bottom: 20px; 49 background-color: #f0f0f0; } 50 51#error_explanation h2 { 52 text-align: left; 53 font-weight: bold; 54 padding: 5px 5px 5px 15px; 55 font-size: 12px; 56 margin: -7px -7px 0; 57 background-color: #c00; 58 color: #fff; } 59 60#error_explanation ul li { 61 font-size: 12px; 62 list-style: square; } 63 64label { 65 display: block; } 66 67 68

試したこと

cssを確認したが、画像を中央よせしているコードは見つからなかった。
htmlのtbodyをdivで囲ってみたが左寄せできなかった。

補足情報(FW/ツールのバージョンなど)

macOS Catalina 10.15.4
rails 6.0.2.2
Ruby 2.6.3p62

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

画像のクラスにcssでこう指定してみてください

css

1.クラス名{ 2 position: absolute; 3 left: 0; 4}

投稿2020/04/23 03:48

chocolate24

総合スコア125

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問