ハンバーガーメニューを押してnavリストを消す。再度ハンバーガーメニューを押すとnavリストを表示させたいのですが、navリストの再表示ができません。
html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Barber Shop -easy tutorials-</title> <link rel="stylesheet" href="style.css"> <link rel="preconnect" href="https://fonts.gstatic.com"> <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@1,200&display=swap" rel="stylesheet"> </head> <body> <section id="banner"> <img class="logo" src="img/logo.png" alt=""> <div class="banner-text"> <h1>Hair Studio</h1> <p>Style Your Hair is Style Your Life</p> <div class="banner-btn"> <a href="#"><span></span>Find Out</a> <a href="#"><span></span>Read More</a> </div> </div> </section> <div id="sideNav"> <nav> <ul> <li><a href="#">HOME</a></li> <li><a href="#">FEATUREs</a></li> <li><a href="#">SERVICES</a></li> <li><a href="#">TESTIMONIALS</a></li> <li><a href="#">CONTACT</a></li> </ul> </nav> </div> <div id="menuBtn"> <img src="img/menu.png" id="menu"> </div> <script> var menuBtn = document.getElementById("menuBtn") var sideNav = document.getElementById("sideNav") var menu = document.getElementById("menu") menuBtn.onclick = function(){ if(sideNav.style.right == "-250px"){ sideNav.style.right == "0"; } else{ sideNav.style.right = "-250px"; } } </script> </body> </html>``` ```ここに言語を入力 css *{ margin: 0; padding: 0; font-family: 'Poppins', sans-serif; } #banner{ background: linear-gradient(rgba(0, 0, 0, 0.5), #009688), url(img/banner.jpg); background-size: cover; background-position: center; height: 100vh; } .logo{ width: 140px; position: absolute; top: 4%; left: 10%; } .banner-text { text-align: center; color: #fff; padding-top: 180px; } .banner-text h1{ font-size: 130px; font-family: 'Kaushan Script', cursive; } .banner-text p{ font-size: 20px; font-style: italic; } .banner-btn{ margin: 70px auto 0; } .banner-btn a{ width: 150px; text-decoration: none; display: inline-block; margin: 0 10px; padding: 12px 0; color: #fff; border: 1px solid #fff; position: relative; z-index: 1; transition: color 0.5s; } .banner-btn a span{ width: 0%; height: 100%; position: absolute; top: 0; left: 0; background: #fff; z-index: -1; transition: 0.5s; } .banner-btn a:hover span{ width: 100%; } .banner-btn a:hover{ color: #000; } #sideNav{ width: 250px; height: 100vh; position: fixed; right: 0px; top: 0; background: #009688; z-index: 2; transition: 0.5s; } nav ul li{ list-style: none; margin: 50px 20px; } nav ul li a{ text-decoration: none; color: #fff; } #menuBtn{ width:50px; height:50px; background: #009688; text-align: center; position: fixed; right: 30px; top: 20px; border-radius: 3px; z-index: 3; cursor: pointer; } #menuBtn img{ width: 20px; margin-top: 15px; }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/11/28 13:27