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 1 year has passed since last update.

imdb clone Part2 4 ヘッダー作成 2/2 タイトルイメージを作成 レイアウトを整理

Last updated at Posted at 2023-05-09

概要

目次

今回はヘッダーのロゴを追加します。
ロゴを右側、その他を左側に配置します。
下図は実装後の様子です。

image.png

開発環境

OS:Windows10
IDE:VSCode

"@next/font": "13.1.5",
"autoprefixer": "10.4.14",
"eslint": "8.39.0",
"eslint-config-next": "13.3.1",
"next": "13.3.1",
"postcss": "8.4.23",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.8.0",
"tailwindcss": "3.3.2"

実装のポイント

1.ヘッダー左側にHome About 右側にロゴを追加する。cssのflex justify-betweenを使います。
image.png

2.ディスプレイサイズ640px以下の場合cloneの文字は非表示されます。
image.png

3.ディスプレイサイズが640以上の場合はcloneは表示されます。
image.png

コード部分

Header

Header.jsx
import MenuItem from "./MenuItem";
import {AiFillHome} from "react-icons/ai"
import {BsFillInfoCircleFill} from "react-icons/bs"
import Link from "next/link";

export default function Header(){
    return(
+        <div className="flex justify-between mx-2 max-w-6xl sm:mx-auto items-center py-6"> 
            <div className="flex">
                <MenuItem title="HOME" address="/" Icon={AiFillHome} />
                <MenuItem title="ABOUT" address="/about" Icon={BsFillInfoCircleFill} />
            </div>

+            <div className="">
+                <Link href="/">
+                <h2 className="text-2xl">
+                    <span className="font-bold bg-amber-500 py-1 px-2 rounded-lg mr-1">IMDb</span>             
+                <span className="text-xl hidden sm :inline">Clone</span>
+                </h2>
+                </Link>                
+           </div>
        </div>
    );
}

参考

css

justify-between

image.png

image.png

max-w-6xl

image.png

py-6

image.png

sm:mx-auto

rounded-lg

image.png

mr-1

その他

Udemy

githubコミット分

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?