0
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.

ナビゲーションヘッダー作成

Posted at

ナビゲーションヘッダー作成する。

https://atom.io/
スクリーンショット 2020-11-17 23.10.44.png

ナビゲーションの土台を作成

.navigation {
    background-color: #584b4f;
    color: #efeae1;
    height: 43px;
}
import React from 'react';
import './AtomPage.css';

export const AtomPage = () => {
    return (
        <>
            <nav className="navigation">
                
            </nav>
        </>
    )
}

↓こうなる
スクリーンショット 2020-11-17 23.14.44.png

メニューの作成

.wrapper {
    margin: 0 auto;
}
import React from 'react';
import './AtomPage.css';

export const AtomPage = () => {
    return (
        <>
            <nav className="navigation">
                <div className="wrapper">
                    <ul>
                        <li>Hoge</li>
                        <li>Fuga</li>
                        <li>Piyo</li>
                    </ul>
                </div>
            </nav>
        </>
    )
}

↓こうなる
スクリーンショット 2020-11-17 23.18.20.png

メニューを横並びにする

・ul要素をinline-blockにすることで横並びにする


.navigation {
    background-color: #584b4f;
    height: 43px;
    padding: 5px 0;
    font-size: 14px;
}

.wrapper {
    margin: 0 auto;
    width: 860px;
}

.navigation ul {
    display : inline-block;
    padding: 0;
    margin: 0;
}

.navigation li {
    display : inline-block;
    padding-right: 10px;
}

.navigation a {
    display: inline-block;
    padding: 5px;
    text-decoration: none;
    color: #efeae1;
}
import React from 'react';
import './AtomPage.css';

export const AtomPage = () => {
    return (
        <>
            <nav className="navigation">
                <div className="wrapper">
                    <ul>
                        <li><a href="">Hoge</a></li>
                        <li><a href="">Fuga</a></li>
                        <li><a href="">Piyo</a></li>
                    </ul>
                </div>
            </nav>
        </>
    )
}

スクリーンショット 2020-11-17 23.33.34.png

右側にSign inボタンつける

・右側用のdivにfloat: rightをつけることで右端まで要素が移動する

.navigation-right {
    float: right;
}

.navigation-right a {
    padding: 5px;
    text-decoration: none;
    color: efeae1;
}
import React from 'react';
import './AtomPage.css';

export const AtomPage = () => {
    return (
        <>
            <nav className="navigation">
                <div className="wrapper">
                    <ul>
                        <li><a href="">Hoge</a></li>
                        <li><a href="">Fuga</a></li>
                        <li><a href="">Piyo</a></li>
                    </ul>

                    <div className="navigation-right">
                        <a href="">Sign in</a>
                    </div>
                </div>
            </nav>
        </>
    )
}

スクリーンショット 2020-11-17 23.36.29.png

0
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
0
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?