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

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

$
0
0

floatプロパティを使って、横並びのメニューを作る方法です。

スクリーンショット 2020-07-21 15.47.42.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;}.navli{float:left;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; 黒丸を消します。
  • float: left; ボタンを横並びにします。
  • line-height: 48px; テキストをボタンの上下中央に配置します。(heightと同じ値にします)
  • text-align: center; テキストをボタンの左右中央に配置します。
  • text-decoration: none; リンクの下線を消します。

参考リンク

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


Viewing all articles
Browse latest Browse all 9004

Trending Articles



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