How TO - アイコン・バー

❮ 前章へ 次章へ ❯

CSS を使用したアイコン・バーの作成方法を学習します。


Vertical:

Horizontal:


アイコン・バーの作成方法

ステップ 1) HTML の追加:

<!-- Add icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">

<div class="icon-bar">
  <a class="active" href="#"><i class="fa fa-home"></i></a>
  <a href="#"><i class="fa fa-search"></i></a>
  <a href="#"><i class="fa fa-envelope"></i></a>
  <a href="#"><i class="fa fa-globe"></i></a>
  <a href="#"><i class="fa fa-trash"></i></a>
</div>

ステップ 2) CSS の追加:

縦型の例

.icon-bar {
    height: 100%;
    width: 90px;
    text-align: center;
    background-color: #555;
}

.icon-bar a {
    padding: 16px;
    display: block;
    transition: all 0.3s ease;
    color: white;
    font-size: 36px;
}

.icon-bar a:hover {
    background-color: #000;
}

.active {
    background-color: #4CAF50;
}
Try it Yourself »

横型の例

.icon-bar {
    width: 100%;
    text-align: center;
    background-color: #555;
    overflow: auto;
}

.icon-bar a {
    width: 20%;
    padding: 12px 0;
    float: left;
    transition: all 0.3s ease;
    color: white;
    font-size: 36px;
}

.icon-bar a:hover {
    background-color: #000;
}

.active {
    background-color: #4CAF50;
}
Try it Yourself »

チップ: ナビゲーションバーの詳細については、CSS Navbar チュートリアルご覧ください。

チップ: アイコンの詳細については、Icons チュートリアルご覧ください。


❮ 前章へ 次章へ ❯