1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【CSS】横に並べる【Chrome】

Posted at

横並びってどうやるんだっけ?

ってなる度に検索しちゃうので覚えるためにも記事にしていきます。

Flexboxで横になりました

なぜフレックスボックスがいいかはMDNさんに書いてありました。
浮動要素と位置指定などはイライラするから らしいです。

.html
<div class="yoko">
    <div class="yokoNarabi">YOKO1</div>
    <div class="yokoNarabi">YOKO2</div>
    <div class="yokoNarabi">YOKO3</div>
    <div class="yokoNarabi">YOKO4</div>
    <div class="yokoNarabi">YOKO5</div>
    <div class="yokoNarabi">YOKO6</div>
</div>
.css
.yoko{
        display: flex;
    }
yoko.html.png

Chromeのデベロッパーで色んな並び方が見れる

これが何よりも楽。
Chrome flex.png

この中でもjustify-contentをよく使うと思うので以下より紹介

justify-content: center;

Chrome_dev_center.png flex_center.png

justify-content: flex-start;

Chrome_dev_start.png flex_start.png

justify-content: flex-end;

Chrome_dev_end.png
flex_end.png

justify-content: space-between;

Chrome_dev_spacebetween.png
flex_spacebetween.png

justify-content: space-around;

Chrome_dev_spacearound.png
flex_spacearound.png

justify-content: space-evenly;

Chrome_dev_spaceevenly.png
flex_spaceevenly.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?