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

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

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

CSS(Cascading Style Sheet)の第3版です。CSS3と略されることが多いです。色やデザインを柔軟に変更することが可能になります。

Ruby on Rails 6

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

HTML5

HTML5 (Hyper Text Markup Language、バージョン 5)は、マークアップ言語であるHTMLの第5版です。

Q&A

解決済

2回答

413閲覧

ボタンの幅がgridを使用しているため縦に長くなってしまっているのを解決したい

tyosu111

総合スコア8

CSS3

CSS(Cascading Style Sheet)の第3版です。CSS3と略されることが多いです。色やデザインを柔軟に変更することが可能になります。

Ruby on Rails 6

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

HTML5

HTML5 (Hyper Text Markup Language、バージョン 5)は、マークアップ言語であるHTMLの第5版です。

0グッド

0クリップ

投稿2023/09/23 11:35

実現したいこと

イメージ説明

・募集部活動検索
・申請中の学校・部活動一覧
こちらのボタンが縦に長くなっているのを解決したいです

前提

理想はCommingSoonの下の余白を上の余白と同じ余白にしたい

該当のソースコード

erb

1<div id="<%= dom_id instructor %>"> 2 <div class="profile_container_action"> 3 <div class="profile_action"> 4 <h4 class="profile_action_mypage">マイページ</h4> 5 <div class="profile_action_application_comming"> 6 <%= link_to '募集部活動検索', my_coach_requests_for_instructor_coach_requests_path, class: 'profile_account_edit', disabled: true %> 7 <p class="comming">Comming Soon</p> 8 </div> 9 <div class="profile_action_application_comming"> 10 <%= link_to '申請中の学校・部活動一覧', my_coach_requests_for_instructor_coach_requests_path, class: 'profile_account_edit', disabled: true %> 11 <p class="comming">Comming Soon</p> 12 </div> 13 <div class="profile_action_application"> 14 <%= link_to '日程が確定した学校・部活動', my_coach_requests_for_instructor_coach_requests_path, class: 'profile_account_edit' %> 15 </div> 16 </div> 17 <div class="profile_container"> 18 <h4 class="profile_title">指導員プロフィール</h4> 19 <p style="color: #9b3938"><%= notice %></p> 20 <div class="profile_content"> 21 <div class="profile_item"> 22 <span class="profile_tag">NAME</span> 23 <%= instructor.name %> 24 </div> 25 <div class="profile_item"> 26 <span class="profile_tag">SCHOOL NAME</span> 27 <%= instructor.school_name %> 28 </div> 29 <div class="profile_item"> 30 <span class="profile_tag">EMAIL</span> 31 <%= instructor.email %> 32 </div> 33 <div class="profile_item"> 34 <span class="profile_tag">CAREER</span> 35 <%= instructor.career %> 36 </div> 37 <div class="profile_item"> 38 <span class="profile_tag">COACH CAREER</span> 39 <%= instructor.coach_career %> 40 </div> 41 <div class="profile_item"> 42 <span class="profile_tag">BIRTHDAY</span> 43 <%= instructor.birthday %> 44 </div> 45 <div class="profile_item"> 46 <span class="profile_tag">TELEPHONE NUMBER</span> 47 <%= instructor.telephone_number %> 48 </div> 49 <div class="profile_item"> 50 <span class="profile_tag">CLUBS</span> 51 <%= instructor.clubs.map(&:name).join(', ') %> 52 </div> 53 </div> 54 <div class="profile_action_content"> 55 <%# <%= button_to "アカウント削除", @instructor, method: :delete, class: "profile_account_delete" %> 56 <%= link_to "編集", edit_instructor_path(@instructor), class: "profile_account_edit"%> 57 </div> 58 </div> 59 </div> 60</div> 61

css

1.profile_container_action { 2 display: flex; 3 justify-content: space-around; 4 /* align-items: center; */ 5} 6 7@media screen and (max-width:768px) { 8 .profile_container_action { 9 display: block; 10 margin: 24px; 11 } 12} 13 14.profile_container { 15 display: grid; 16 margin: 24px; 17} 18 19.profile_title { 20 font-size: 32px; 21 margin: 18px; 22} 23 24@media screen and (max-width:768px) { 25 .profile_title { 26 font-size: 24px; 27 text-align: center; 28 margin: 0; 29 } 30} 31 32.profile_content { 33 width: 600px; 34} 35 36@media screen and (max-width:768px) { 37 .profile_content { 38 width: auto; 39 } 40} 41 42.profile_item { 43 display: grid; 44 gap: 4px; 45 margin: 14px 0px; 46 border-bottom: 1px solid #666666; 47 padding: 12px 0px; 48} 49 50span.profile_tag { 51 font-size: 12px; 52 color: #666666; 53 font-weight: bold; 54} 55 56.profile_action_content { 57 display: flex; 58 justify-content: flex-end; 59} 60 61.profile_account_delete { 62 background-color: transparent; 63 border: none; 64 cursor: pointer; 65 outline: none; 66 padding: 0; 67 appearance: none; 68 color: #666666; 69} 70 71.profile_account_edit { 72 padding-right: 8px; 73 color: #333; 74 text-decoration: none; 75} 76 77.profile_action { 78 display: grid; 79 80 gap: 32px; 81 82} 83 84@media screen and (max-width:768px) { 85 .profile_action { 86 padding: 18px; 87 } 88} 89 90.profile_action_mypage { 91 font-size: 32px; 92} 93 94.profile_action_application_comming { 95 display: inline-block; /* inline-blockに変更 */ 96 position: relative; /* 相対位置に設定 */ 97 padding: 18px 114px; 98 border: 3px solid #333; 99 border-radius: 20px; 100 font-weight: bold; 101 cursor: pointer; /* カーソルをポインターに変更 */ 102 text-align: center; /* テキストを中央揃えに変更 */ 103 text-decoration: none; /* テキストの下線を削除 */ 104 overflow: hidden; /* 親要素からはみ出さないようにする */ 105 box-shadow: 10px 10px 0px -5px #333; 106} 107 108.profile_action_application { 109 display: inline-block; /* inline-blockに変更 */ 110 position: relative; /* 相対位置に設定 */ 111 padding: 28px; 112 border: 3px solid #333; 113 border-radius: 20px; 114 font-weight: bold; 115 cursor: pointer; /* カーソルをポインターに変更 */ 116 text-align: center; /* テキストを中央揃えに変更 */ 117 text-decoration: none; /* テキストの下線を削除 */ 118 overflow: hidden; /* 親要素からはみ出さないようにする */ 119 box-shadow: 10px 10px 0px -5px #333; 120} 121 122.profile_action_application:hover { 123 background-color: #ede9e9; 124} 125 126@media screen and (max-width:768px) { 127 .profile_action_application_comming { 128 padding: 12px; 129 width: auto; 130 font-size: 14px; 131 } 132} 133 134@media screen and (max-width:768px) { 135 .profile_action_application { 136 padding: 24px; 137 width: auto; 138 font-size: 14px; 139 } 140} 141 142p.comming { 143 margin: 0; 144} 145 146label.instructor_checkbox { 147 display: flex; 148 align-items: center; 149 font-size: 15px; 150} 151

Gridを使用して実装使用としましたがわからず教えていただけますと幸いです。
よろしくお願い致します。

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

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

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

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

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

guest

回答2

0

 pecmm さんのご回答の通りなのですが、補足します。

css

1.profile_action_application_comming { 2 display: inline-block; /* inline-blockに変更 */

となっていますが、

css

1.profile_action { 2 display: grid;

としているため、上手く動作しません。

 グリッドレイアウトの直接の子要素(グリッドアイテム)は、インラインレベルボックスであっても「ブロック化(Blockification)」されます。

参考: 

If the computed display value of an element’s nearest ancestor element (skipping display:contents ancestors) is grid or inline-grid, the element’s own display value is blockified.
6.1. Grid Item Display | CSS Grid Layout Module Level 1

 

Some layout effects require blockification or inlinification of the box type, which sets the box’s computed outer display type to block or inline (respectively).
...
For legacy reasons, if an inline block box (inline flow-root) is blockified, it becomes a block box (losing its flow-root nature). For consistency, a run-in flow-root box also blockifies to a block box.
2.7. Automatic Box Type Transformations | CSS Display Module Level 3

投稿2023/09/28 01:51

編集2023/09/28 01:53
Lhankor_Mhy

総合スコア37421

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

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

tyosu111

2023/09/28 02:45

Lhankor_Mhy様 補足ありがとうございます。 これらを踏まえまして、学んでいけたらと思います。 どうか今後ともよろしくお願い申し上げます。
guest

0

ベストアンサー

おそらく当該gridに対するブロック軸上配置のスタイル指定がなく、デフォルトでalign-items: stretchの挙動になっているのだと思います。

https://developer.mozilla.org/ja/docs/Web/CSS/align-items
説明がちょっとややこしいので、上記MDNページの「試してみましょう」で
stretchとかcenterとかstartを選んでみてください。

実際のcssでstretch以外の値を指定すれば、内側のコンテンツに合わせた高さで指定の位置に描画されるはずです。


https://developer.mozilla.org/ja/docs/Web/CSS/CSS_grid_layout/Box_alignment_in_grid_layout
grid内配置の詳細は上記MDNページが参考になります。

また、モダンなブラウザの開発者ツールであれば、指定のgirdやflexの補助線を表示する機能等がついていたりします。
これらを駆使して色々試して確認しながら調整するときっとよい感じになるでしょう

投稿2023/09/23 18:52

pecmm

総合スコア760

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

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

tyosu111

2023/09/28 02:44

ご丁寧な回答ありがとうございます。 また参考URLも大変ありがとうございます! 引き続きよろしくお願い致します!!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.31%

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

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

質問する

関連した質問