LoginSignup
4
4

More than 5 years have passed since last update.

ブロック全体をリンクに -フッター用メニューを作る1-

Last updated at Posted at 2016-03-29

下のようなスマホ用webサイトのフッターメニューを作りたい(画像はドコモのサイトから拝借しました)

スクリーンショット 2016-03-29 23.39.16.png

HTML

HTML
<ul>
    <li><a href="#">メニュー1</a></li>
    <li><a href="#">メニュー2</a></li>
    <li><a href="#">メニュー3</a></li>
    <li><a href="#">メニュー4</a></li>
    <li><a href="#">メニュー5</a></li>
    <li><a href="#">メニュー6</a></li>
</ul>

メニューを縦と横に並べる

liのwidthを50%にしてfloatで並べる。
ulのafter擬似要素を使ってfloatをクリアする。

liを並べる
ul:after {
     content: "";
     display: block;
     clear: both;
}
li {
     float: left;
     width: 50%;
}

ブロック全体をリンクにする

aのdisplayをblockにしてwidthを100%にする。

ブロック全体をリンクに
a {
     display: block;
     width: 100%;
}

結果

現時点での結果はこちら
見た目的にはまだまだ。
文字を中央にしたり三角のアイコンを作ったりなどの問題が残るがそれは明日やるつもり。

全体のコード
<!DOCTYPE html>
<html>
    <head>
    <style type="text/css">
     * {
         margin: 0;
         padding: 0;
     }
     ul {
         list-style: none;
     }
     ul:after {
         content: "";
         display: block;
         clear: both;
     }
     li {
         float: left;
         width: 50%;
         border: solid 1px #000;
         box-sizing: border-box;
     }
     a {
         display: block;
         width: 100%;
         text-align: center;
     }
    </style>
    </head>
    <body>
    <ul>
        <li><a href="#">メニュー1</a></li>
        <li><a href="#">メニュー2</a></li>
        <li><a href="#">メニュー3</a></li>
        <li><a href="#">メニュー4</a></li>
        <li><a href="#">メニュー5</a></li>
        <li><a href="#">メニュー6</a></li>
    </ul>
    </body>
</html>

続き

4
4
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
4
4