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?

More than 3 years have passed since last update.

【css】リスト(li)を横並び、かつ中央寄せにする方法!

Last updated at Posted at 2021-11-06

リストに使う、「ul」や「li」を横並びで中央に寄せようとするとうまくいかなかったため、これならできたぁってのを載せておきます!

簡易的なリスト↓

list.html
<ul>
 <li>リスト1</li>
 <li>リスト2</li>
 <li>リスト3</li>
</ul>

これさえあれば、横並び中央にできる↓

list.css
ul {
 text-align: center;
}

li {
 display: inline;
}

これだけだと、余白だったりが気になるので、
li部分にmarginを仕込むといいですよ!

ちなみに、floatを使うとうまくいかんかった(T-T)
正直、float使うと、「・」を取るコードが必要なんやけど、**display: inline;**使うと勝手に無くなってくれるのでコードの短縮にもつながる!

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?