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

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

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

BootstrapはウェブサイトデザインやUIのWebアプリケーションを素早く 作成する可能なCSSフレームワークです。 Twitter風のデザインを作成することができます。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

Q&A

解決済

1回答

4882閲覧

ブートストラップのカードを縦並びと横並びを混ぜて表示したい。

yumaaaa

総合スコア4

Bootstrap

BootstrapはウェブサイトデザインやUIのWebアプリケーションを素早く 作成する可能なCSSフレームワークです。 Twitter風のデザインを作成することができます。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

CSS

CSSはXMLやHTMLで表現した色・レイアウト・フォントなどの要素を指示する仕様の1つです。

0グッド

0クリップ

投稿2021/01/27 09:17

ブートストラップのカードを縦並びと横並びを混ぜて表示したい。

ブートストラップのカードを3つのクラスに分けて、それぞれのクラスに3つ縦にカードを並べてから横にクラスを並べるように表示して行きたいのですが、全て縦並びになるので、改善したいです。

該当のソースコード

html

1div class="a"> 2 3<div class="l"> 4 5<div class="card1" style="width: 18rem;"> 6 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 7 <div class="card-body"> 8 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 9 </div> 10</div> 11 12<div class="card1" style="width: 18rem;"> 13 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 14 <div class="card-body"> 15 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 16 </div> 17</div> 18 19<div class="card1" style="width: 18rem;"> 20 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 21 <div class="card-body"> 22 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 23 </div> 24</div> 25 26</div> 27 28<div class="c"> 29 30<div class="card1" style="width: 18rem;"> 31 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 32 <div class="card-body"> 33 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 34 </div> 35</div> 36 37<div class="card1" style="width: 18rem;"> 38 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 39 <div class="card-body"> 40 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 41 </div> 42</div> 43 44<div class="card1" style="width: 18rem;"> 45 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 46 <div class="card-body"> 47 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 48 </div> 49</div> 50 51</div> 52 53<div class="c"> 54 55<div class="card1" style="width: 18rem;"> 56 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 57 <div class="card-body"> 58 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 59 </div> 60</div> 61 62<div class="card1" style="width: 18rem;"> 63 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 64 <div class="card-body"> 65 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 66 </div> 67</div> 68 69<div class="card1" style="width: 18rem;"> 70 <svg class="bd-placeholder-img card-img-top" width="100%" height="180" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Image cap"><title>Placeholder</title><rect fill="#868e96" width="100%" height="100%"/><text fill="#dee2e6" dy=".3em" x="50%" y="50%">Image cap</text></svg> 71 <div class="card-body"> 72 <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> 73 </div> 74</div> 75 76</div> 77 78 79</div>

css

1.card1 { 2 margin-left: 10px; 3 margin-bottom: 20px; 4}

イメージ説明
イメージ説明

試したこと

どのプロパティでもなかなかうまく行きませんでいた。

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

簡単なことかもしれませんが、ご協力お願いいたします。

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

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

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

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

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

yumaaaa

2021/01/29 05:12

お返事遅れ申し訳ございません。 カードクラスを使用して無事解決いたしました。 お力添えありがとうございます。
guest

回答1

0

ベストアンサー

こんにちは。

HTML+CSSでは、何もしない場合、ブロックレイアウトになります。
ブロックレイアウトは、何もしない場合、ブロックが縦方向に並んでいきます。
そして、ご提示のコードは、何もしていないので、ブロックが縦方向に並んでいくことになります。

通常フローでは、インライン要素はインライン方向、つまり文書の書字方向に従って、文の中で言葉が表示される方向に表示されます。ブロック要素は、文書の書字方向の中で、段落として一つが他の物の後に表示されます。従って英語では、インライン要素は左から始まり、一つが他の物の後に表示され、ブロック要素は上から始まり、ページの下に向かいます。

CSS フローレイアウト - CSS: カスケーディングスタイルシート | MDN

つまり、文字は右から左へ、段落は上から下へ配置される、ということです。
ワードなどで文書を作ったことはありますか? あれと同様です。
これは、基本中の基本なので、しっかり理解されることをおすすめします。


つまり、横並びにするには、何かを指定しないといけない、ということです。
横並びにする方法はいろいろありますが、フレックスレイアウトが一番お手軽だと思います。
そして、Bootstrap では、.rowをつけるとその要素がフレックスコンテナになりますので、それを利用するのが手っ取り早いです。


解決方法ですが、<div class="a"><div class="a row">としてみてはいかがでしょうか。

投稿2021/01/28 03:03

Lhankor_Mhy

総合スコア35871

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

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

yumaaaa

2021/01/29 05:12

お返事ありがとうございます。 カードクラスとrowをうまく合わせると可能になりました。 ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問