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="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/hamburgers.min.css"> </head> <body> <header> <h1>shop-site</h1> <nav id="g-nav-pc"> <ul> <li><a href="#top">トップ</a></li> <li><a href="#item">アイテム</a></li> <li><a href="#shop">店舗情報</a></li> <li><a href="#help">よくある質問</a></li> </ul> </nav> </header> <div class="content-wrapper"> <div class="logo-box"> </div> <div class="container"> <div class="sp-header"> <h2>shop-site</h2> <p class="hamburger hamburger--stand" id="ham-btn"> <span class="hamburger-box"> <span class="hamburger-inner"></span> </span> </p> </div><!-- /.sp-header --> <nav id="g-nav-sp"> <ul> <li><a href="#top">トップ</a></li> <li><a href="#item">アイテム</a></li> <li><a href="#shop">店舗情報</a></li> <li><a href="#help">よくある質問</a></li> </ul> </nav> <main> <div class="main-visual"> <img src="https://picsum.photos/id/237/960/800" alt=""> </div><!-- /.main-visual --> <div class="main-copy"> </div><!-- /.main-copy --> <div id="item" class="category"> <h3 data-en="Item">商品情報</h3> <div class="photo-wrapper"> <div class="photo-box"> <img src="img/photo-1.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> <div class="photo-box"> <img src="img/photo-2.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> <div class="photo-box"> <img src="img/photo-3.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> <div class="photo-box"> <img src="img/photo-4.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> <div class="photo-box"> <img src="img/photo-5.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> <div class="photo-box"> <img src="img/photo-6.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> <div class="photo-box"> <img src="img/photo-7.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> <div class="photo-box"> <img src="img/photo-8.jpg" alt=""> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore, nisi?</p> </div><!-- /.photo-box --> </div><!-- /.photo-wrapper --> </div><!-- /#item --> <div id="shop" class="category"> <h3 data-en="Shop">店舗情報</h3> <dl class="shop-list"> <dt>住所</dt> <dd>東京都豊島区南池袋x-x-x</dd> <dt>電話番号</dt> <dd class="phone-num"><a href="tel:03-1234-5678">03-1234-5678</a></dd> <dt>営業時間</dt> <dd>11:00~20:00</dd> <dt>定休日</dt> <dd>水曜日</dd> </dl> <div class="map"> <iframe class="g-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3238.9454663323195!2d139.7121211499927!3d35.72755968008629!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x60188d68f6cfe057%3A0xddd17dcd7ecaf745!2z6LGK5bO25Yy656uL5Y2X5rGg6KKL5YWs5ZyS!5e0!3m2!1sja!2sjp!4v1674526066448!5m2!1sja!2sjp" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe> </div> </div><!-- /#shop --> <div id="help" class="category"> <h3 data-en="FAQ">よくある質問</h3> <div class="accordion"> <details open> <summary> <h4 data-question="Q">返品・交換はできますか?</h4> </summary> <p data-answer="A">室内での試し履き、化粧箱があれば返品・同商品のサイズ交換対応をしております。</p> </details> <details> <summary> <h4 data-question="Q">注文した商品はいつ届きますか。</h4> </summary> <p data-answer="A">神奈川県の配送センターより出荷し、国内であればご注文日から2、3日前後でお届けいたします。</p> </details> <details> <summary> <h4 data-question="Q">コンビニ受け取りはできますでしょうか。</h4> </summary> <p data-answer="A">当ストアではコンビニ受け取りサービスは行っておりません。</p> </details> </div><!-- /.accordion --> </div><!-- /#help --> </main> <footer> <p><small>© 2017-<span id="this-year"></span> shop-site All rights reserved</small></p> </footer> </div><!-- /.container --> </div><!-- /.content-wrapper --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script> $(function(){ //西暦の取得 let fullYear = new Date().getFullYear(); console.log(fullYear); $('#this-year').text(fullYear); //#ham-btnをclickしたら $('#ham-btn').on('click',function(){ $(this).toggleClass('is-active'); $('#g-nav-sp').toggleClass('move'); }); //#g-nav-sp aをclickしたら $('#g-nav-sp a').on('click',function(){ $('#g-nav-sp').removeClass('move'); $('#ham-btn').removeClass('is-active'); }); }); </script> </body> </html>
style.css
@charset "utf-8"; :root{ --main_color:#546c91; } html{box-sizing:border-box;-webkit-text-size-adjust:100%}*,:after,:before{background-repeat:no-repeat;box-sizing:inherit}:after,:before{text-decoration:inherit;vertical-align:inherit}*{padding:0;margin:0;box-sizing:border-box;}audio:not([controls]){display:none;height:0}hr{overflow:visible}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}summary{display:list-item}small{font-size:80%}[hidden],template{display:none}abbr[title]{border-bottom:1px dotted;text-decoration:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}code,kbd,pre,samp{font-family:monospace,monospace}b,strong{font-weight:bolder}dfn{font-style:italic}mark{background-color:#ff0;color:#000}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}input{border-radius:0}[role=button],[type=button],[type=reset],[type=submit],button{cursor:pointer}[disabled]{cursor:default}[type=number]{width:auto}[type=search]{-webkit-appearance:textfield}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}textarea{overflow:auto;resize:vertical}button,input,optgroup,select,textarea{font:inherit}optgroup{font-weight:700}button{overflow:visible}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:0;padding:0}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button:-moz-focusring{outline:1px dotted ButtonText}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}button,select{text-transform:none}button,input,select,textarea{background-color:transparent;border-style:none;color:inherit}select{-moz-appearance:none;-webkit-appearance:none}select::-ms-expand{display:none}select::-ms-value{color:currentColor}legend{border:0;color:inherit;display:table;max-width:100%;white-space:normal}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}img{border-style:none;vertical-align: bottom}progress{vertical-align:baseline}svg:not(:root){overflow:hidden}audio,canvas,progress,video{display:inline-block}@media screen{[hidden~=screen]{display:inherit}[hidden~=screen]:not(:active):not(:focus):not(:target){position:absolute!important;clip:rect(0 0 0 0)!important}}[aria-busy=true]{cursor:progress}[aria-controls]{cursor:pointer}[aria-disabled]{cursor:default}::-moz-selection{background-color:#b3d4fc;color:#000;text-shadow:none}::selection{background-color:#b3d4fc;color:#000;text-shadow:none}ul,ol{list-style:none;}a{text-decoration:none;}.wrapper{overflow:hidden;}body{overflow-y:scroll;}img{max-width: 100%;} html{ scroll-behavior: smooth; } body{ width: 100%; height: 100vh; background-repeat: repeat; background-attachment: fixed;/* iosでは効かない */ background-color: #edf1e5; background-image: url("data:image/svg+xml,%3Csvg width='84' height='48' viewBox='0 0 84 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h12v6H0V0zm28 8h12v6H28V8zm14-8h12v6H42V0zm14 0h12v6H56V0zm0 8h12v6H56V8zM42 8h12v6H42V8zm0 16h12v6H42v-6zm14-8h12v6H56v-6zm14 0h12v6H70v-6zm0-16h12v6H70V0zM28 32h12v6H28v-6zM14 16h12v6H14v-6zM0 24h12v6H0v-6zm0 8h12v6H0v-6zm14 0h12v6H14v-6zm14 8h12v6H28v-6zm-14 0h12v6H14v-6zm28 0h12v6H42v-6zm14-8h12v6H56v-6zm0-8h12v6H56v-6zm14 8h12v6H70v-6zm0 8h12v6H70v-6zM14 24h12v6H14v-6zm14-8h12v6H28v-6zM14 8h12v6H14V8zM0 8h12v6H0V8z' fill='%23a1b6b5' fill-opacity='0.27' fill-rule='evenodd'/%3E%3C/svg%3E"); } header{ width: 100%; height: 80px; background-color: #FFFFFFAA; backdrop-filter: blur(6px); position: fixed; top: 0; left: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; } #g-nav-pc>ul{ display: flex; } #g-nav-pc li{ margin: 0 20px; } #g-nav-pc a{ padding: 20px; color: #222; font-weight: bold; } #g-nav-pc a:hover{ text-decoration: underline 4px #cb5555; text-underline-offset: 4px; } .content-wrapper{ display: flex; flex-direction: row-reverse; } .logo-box{ width: 300px; aspect-ratio: 1 / 1; background-color: #42507b; position: fixed; top: 140px; left: 200px; } /* container部分のスタイル */ .container{ max-width: 560px; background-color: #FFF; margin:120px 50px 50px 0; box-shadow: 0 0 6px #AAA; } .main-visual{ width: 100%; height: 70vh; } .main-visual>img{ object-fit: cover; width: 100%; height: 100%; } .category{ padding: 120px 10px 40px; } /* カテゴリーの見出し */ .category>h3{ text-align: center; font-size: 28px; margin-bottom: 20px; } .category>h3::before{ content: attr(data-en); font-size: 24px; color: var(--main_color); display: block; font-family: serif; } /* item部分 */ .photo-wrapper{ columns: 2; } .photo-box{ break-inside: avoid;/* photo-box内で改行させない */ background-color: #e1e2ec; margin-bottom: 20px; padding: 10px; } /* 店舗情報部分 */ .shop-list{ display: flex; flex-wrap: wrap; border: 1px solid #333; margin-bottom: 80px; } .shop-list>dt{ width: 25%; background-color: var(--main_color); color: #FFF; padding: 20px; border-right: 1px solid #333; } .shop-list>dd{ width: 75%; padding: 20px; } .shop-list>:is(dt:nth-of-type(n+2),dd:nth-of-type(n+2)){ border-top: 1px solid #333; } .phone-num>a{ pointer-events: none;/* a要素がクリック出来なくなる */ color: #222; } /* map部分 */ .map{ width: 100%; aspect-ratio: 16 / 9;/* 要素の大きさをアスペクト比で設定、横:縦 */ } .g-map{ width: 100%; height: 100%; } /* FAQ部分 */ summary{ list-style: none;/* 黒い三角形を消す */ } summary::-webkit-details-marker { display: none;/* iOS仕様 */ } details{ margin-bottom: 40px; } summary{ background-color: var(--main_color); font-size: 20px; color: #FFF; padding: 14px; cursor: pointer; } summary>h4::before{ content: attr(data-question); background-color: #FFF; color: #eb6262; padding: 4px 10px; border-radius: 50%; margin-right: 20px; } details>p{ background-color: #eaf5f5; padding: 20px; } footer{ width: 100%; background-color: var(--main_color); } footer>p{ text-align: center; padding: 30px 0; color: #FFF; font-size: 18px; } /* sp用のheaderを隠す */ .sp-header{ display: none; } #g-nav-sp{ display: none; } @media (max-width:1166px){ .logo-box{ width: 200px; top: 140px; left: 40px; } } @media (max-width:960px){ .logo-box{ display: none; } /* navをsp用に切り替える */ header{ display: none; } .container{ margin: 0 auto; } .sp-header{ display: flex; justify-content: space-between; height: 80px; width: 100%; align-items: center; padding-left: 15px; position: fixed; top: 0; left: 0; background-color: #FFFFFFAA; backdrop-filter: blur(6px); } main{ padding-top: 80px; } /* sp用ナビゲーション */ #g-nav-sp{ display: block; width: 100%; height: calc(100vh - 80px); position: fixed; left: 0; top: 80px; background-color: var(--main_color); padding: 40px; transform: translateX(-100%); transition: 0.2s; } #g-nav-sp.move{ transform: translateX(0); } #g-nav-sp li{ margin-bottom: 20px; } #g-nav-sp a{ display: block; color: #FFF; padding: 10px 0; border-bottom: 1px solid #FFF; } } @media (max-width:440px){ .photo-wrapper{ columns: 1; } }