index.html
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>モバイル幅でサイトを作成する</title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Yusei+Magic&display=swap" rel="stylesheet"> <link rel="stylesheet" href="css/style.css"> </head> <body id="top"> <header> <h1>フェリカスポーツ</h1> <nav id="pc-nav"> <ul> <li><a href="#top">トップ</a></li> <li><a href="#concept">コンセプト</a></li> <li><a href="#item">商品情報</a></li> <li><a href="#shop">店舗案内</a></li> </ul> </nav> </header> <div class="logo-wrapper"> <div class="logo"> <img src="img/logo.svg" alt=""> </div> <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Non, fugiat.</p> </div> <div class="container"> <div class="sp-header"> <h2 class="sp-title">フェリカスポーツ</h2> </div><!-- /.sp-header --> <nav id="sp-nav"> <ul> <li><a href="#top">トップ</a></li> <li><a href="#concept">コンセプト</a></li> <li><a href="#item">商品情報</a></li> <li><a href="#shop">店舗案内</a></li> </ul> </nav> <main> <div class="main-visual"> <img src="img/main.jpg" alt=""> </div> <div id="concept"> <h3>コンセプト</h3> </div><!-- /#concept --> <div id="item"> <h3>商品情報</h3> </div><!-- /#item --> <div id="shop"> <h3>店舗案内</h3> </div><!-- /#shop --> </main> <p><a href="#top">トップに戻る</a></p> <footer> <p><small>© 2022 フェリカスポーツ</small></p> </footer> </div><!-- /.container --> </body> </html>
style.css
body{ width: 100%; height: 100svh; background: #ede9d8 fixed; padding-top: 100px; } h1,h2,h3{ font-family: 'Yusei Magic', sans-serif; } header{ width: 100%; height: 80px; position: fixed; top: 0; left: 0; background-color: #FFFFFF88; backdrop-filter: blur(10px); display: flex; justify-content: space-between; padding: 0 30px; align-items: center; box-shadow: 0 5px 5px #cacaca; } #pc-nav{ width: 50%; } #pc-nav>ul{ display: flex; justify-content: center; } #pc-nav li{ margin: 0 20px; } #pc-nav a{ padding: 16px; color: #333; font-family: 'Yusei Magic', sans-serif; font-size: 18px; } #pc-nav a:hover{ text-decoration: underline 4px #b6d632; text-underline-offset: 4px; } .logo-wrapper{ width: 30%; height: 300px; position: fixed; left: 100px; top: 140px; padding: 20px; } .logo-wrapper>p{ margin: 10px 0; } .container{ max-width: 540px; margin: 0 0 100px 50%; background-color: #FFF; box-shadow: 0 0 5px #AAA; } main>div{ height: 200vh; } main h3{ text-align: center; font-size: 30px; } /* メインビジュアル部分 */ .main-visual{ width: 100%; height: 400px; } .main-visual>img{ object-fit: cover; object-position: center center; width: 100%; height: 100%; } /* スムーススクロール */ html{ scroll-behavior: smooth; } main>div{ scroll-margin-top: 100px; } #sp-nav{ display: none; }