0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CSS の配置

Posted at

自分用の備忘録。
真ん中にしたいのになかなかできない

1つずつ載せる。

#Hamlは共通
.payment-information
.payment-information__form
%span.payment-information__form--item-price ¥680
%span.payment-information__form--item-shipping 送料込み
.payment-information__form--point
%button{:type => "submit"} ポイントはありません

#1-1 SCSS
.payment-information{
width:320px;
height: 300px;
margin: 0 auto;
background-color: aqua;
text-align: center;
&__form{
display: flex;
justify-content: center;
&--item-price{
font-weight: bold;
}
&--item-shipping{
color: red;
font-weight: normal;
margin-left: 20px;
}
}
}
#1-2
スクリーンショット 2019-06-26 16.12.33.png

#2-1
.payment-information{
width:320px;
height: 300px;
margin: 0 auto;
background-color: aqua;
text-align: center;
&__form{
// display: flex;
// justify-content: center;
&--item-price{
font-weight: bold;
}
&--item-shipping{
color: red;
font-weight: normal;
margin-left: 20px;
}
}
}
#2-2
スクリーンショット 2019-06-26 16.18.53.png

#3-1
.payment-information{
width:320px;
height: 300px;
margin: 0 auto;
background-color: aqua;
text-align: center;
&__form{
display: flex;
justify-content: center;
&--item-price{
font-weight: bold;
}
&--item-shipping{
color: red;
font-weight: normal;
margin-left: 20px;
}
}
}

#3-2
スクリーンショット 2019-06-26 16.20.41.png

親要素にtext-align: center;をしているので、全て真ん中に行くかと思いきや、行かなかった。
子要素にdisplay:flex;がある為だった。
子要素のdisplay:flex;を外すか、justify-content: center;を記述する事で解決!

justify-contentは「display:flex;」したやつをどこに置くのかを指定できるとのこと。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?