ハンバーガーメニューが適用されません
スマホサイズでみると、headerが細くなり、ハンバーガーメニューの三本線が出てきません・・・
HTML
1 <!-- header --> 2 <header class="header" id="header"> 3 <div class="header-inner"> 4 <nav class="header-nav"> 5 <ul class="nav-list"> 6 <li class="nav-item"><a href="#fv">top</a></li> 7 <li class="nav-item"><a href="#design">design</a></li> 8 <li class="nav-item"><a href="#about">about</a></li> 9 <li class="nav-item"><a href="#skills">skills</a></li> 10 </ul> 11 </nav> 12 <button class="burger-btn"> 13 <span class="bar bar_top"></span> 14 <span class="bar bar_mid"></span> 15 <span class="bar bar_bottom"></span> 16 </button> 17 </div> 18 </header> 19 <!-- //header -->
CSS
1 /* ------------------- */ 2 /* header_sp */ 3 /* ------------------- */ 4 .header{ 5 padding: 30px 4vw 0; 6 } 7 .header-nav{ 8 display: none; 9 position: fixed; 10 top: 0; 11 left: 0; 12 width: 100%; 13 height: 100vh; 14 background-color: #A5BDC6; 15 } 16 .nav-list{ 17 height: 100%; 18 flex-direction: column; 19 justify-content: center; 20 align-items: center; 21 } 22 .nav-item{ 23 margin:0 0 30px; 24 } 25 .nav-item:last-of-type{ 26 margin-bottom: 0; 27 } 28 29 .burger-btn{ 30 display: block; 31 position: absolute; 32 top: 30px; 33 right: 4vw; 34 } 35 .burger-btn .bar{ 36 display: block; 37 height: 3px; 38 width: 30px; 39 background-color: #fff; 40 transition: .3s; 41 } 42 .bar_top, 43 .bar_mid{ 44 margin-bottom: 8px; 45 } 46 47 .burger-btn.cross .bar_top{ 48 transform: rotate(45deg) translate(8px,8px); 49 transition: .3s; 50 } 51 .burger-btn.cross .bar_mid{ 52 opacity: 0; 53 transition: .3s; 54 } 55 .burger-btn.cross .bar_bottom{ 56 transform: rotate(-45deg) translate(8px,-8px); 57 transition: .3s; 58 } 59 body.noscroll{ 60 overflow: hidden; 61} 62 button{ 63 background-color: transparent; 64 border: none; 65 cursor: pointer; 66 outline: none; 67 padding: 0; 68 appearance: none; 69 }
JS
1//ハンバーガーメニュー 2$('.burger-btn').on('click',function(){ 3 $('.header-nav').fadeToggle(300); 4 $(this).toggleClass('cross'); 5 $('body').toggleClass('noscroll'); 6});
回答1件
あなたの回答
tips
プレビュー