Quantcast
Channel: CSSタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8816

【CSS3】横並びメニューの作り方(FlexBox編)

$
0
0

FlexBox(display: flex;)を使って、横並びのメニューを作る方法です。

スクリーンショット 2020-07-21 19.18.16.png

index.html
<ulclass="nav"><li><ahref="#">Menu1</a></li><li><ahref="#">Menu2</a></li><li><ahref="#">Menu3</a></li></ul>
style.css
.nav{list-style:none;display:flex;}.navli{width:160px;height:48px;line-height:48px;text-align:center;background-color:#333;}.navlia{text-decoration:none;color:#fff;font-weight:bold;}
  • list-style: none; 黒丸を消します。
  • display: flex; ボタンを横並びにします。
  • line-height: 48px; テキストをボタンの上下中央に配置します。(heightと同じ値にします)
  • text-align: center; テキストをボタンの左右中央に配置します。
  • text-decoration: none; リンクの下線を消します。

参考リンク

【CSS3】横並びメニューの作り方(float編)
【CSS3】横並びメニューの作り方(inline-block編)


Viewing all articles
Browse latest Browse all 8816

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>