Bootstrapを利用してハンバーガーメニューを作成したんですが、うまく開かないです。
具体的にはハンバーガメニューのアイコンはあるのですが、押しても反応せず、ナビゲーションメニューがドロップダウンしません。
今まで、試したこと 確認したこと:
1 js jqueryなどBootstrap関連のファイルの抜け忘れ確認
2 head内に記述しているscriptをbodyの閉じタグの直前に移動した
3 直接は関係ないと思いますが、li a などのリンク先に#をつけた場合と""のみで指定なしの場合両方試しました。
該当のソースコードを載せるので確認お願い致します。
HTML
1<!DOCTYPE html> 2<html lang="ja"> 3<head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1"> 6 <title>Complete Bootstrap 4 Website Layout</title> 7 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> 8 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 9 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script> 10 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script> 11 <script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script> 12 <link href="style.css" rel="stylesheet"> 13</head> 14<body> 15 16<!-- Navigation --> 17<nav class="navbar navbar-expand-md navbar-light bg-light sticky-top"> 18<div class="container-fluid"> 19<a class="navbar-brand" href=""><img src="img/logo.png"></a> 20<button class="navbar-toggler" type="button" date-toggle="collapse" 21date-target="#navbarResponsive"> 22 <span class="navbar-toggler-icon"></span> 23</button> 24<div class="collapse navbar-collapse" id="navbarResponsive"> 25 <ul class="navbar-nav ml-auto"> 26 <li class="nav-item active"> 27 <a class="nav-link" href="">Home</a> 28 </li> 29 <li class="nav-item"> 30 <a class="nav-link" href="">About</a> 31 </li> 32 <li class="nav-item"> 33 <a class="nav-link" href="">Services</a> 34 </li> 35 <li class="nav-item"> 36 <a class="nav-link" href="">Team</a> 37 </li> 38 <li class="nav-item"> 39 <a class="nav-link" href="">Connect</a> 40 </li> 41 </ul> 42</div> 43</div> 44</nav> 45 46<!--- Image Slider --> 47 48 49<!--- Jumbotron --> 50 51 52<!--- Welcome Section --> 53 54 55<!--- Three Column Section --> 56 57 58<!--- Two Column Section --> 59 60 61<!--- Fixed background --> 62 63 64<!--- Emoji Section --> 65 66 67<!--- Meet the team --> 68 69 70<!--- Cards --> 71 72 73<!--- Two Column Section --> 74 75 76<!--- Connect --> 77 78 79<!--- Footer --> 80 81 82 83 84</body> 85</html> 86
念のためにcssファイルも載せておきます。
css
1@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,700'); 2 3 4 5 6 7 8 9 10 11 12 13/*---Media Queries --*/ 14@media (max-width: 992px) { 15 16 } 17@media (max-width: 768px) { 18 19} 20@media (max-width: 576px) { 21 22} 23 24 25/*---Firefox Bug Fix --*/ 26.carousel-item { 27 transition: -webkit-transform 0.5s ease; 28 transition: transform 0.5s ease; 29 transition: transform 0.5s ease, -webkit-transform 0.5s ease; 30 -webkit-backface-visibility: visible; 31 backface-visibility: visible; 32} 33/*--- Fixed Background Image --*/ 34figure { 35 position: relative; 36 width: 100%; 37 height: 60%; 38 margin: 0!important; 39} 40.fixed-wrap { 41 clip: rect(0, auto, auto, 0); 42 position: absolute; 43 top: 0; 44 left: 0; 45 width: 100%; 46 height: 100%; 47} 48#fixed { 49 background-image: url('img/mac.png'); 50 position: fixed; 51 display: block; 52 top: 0; 53 left: 0; 54 width: 100%; 55 height: 100%; 56 background-size: cover; 57 background-position: center center; 58 -webkit-transform: translateZ(0); 59 transform: translateZ(0); 60 will-change: transform; 61} 62/*--- Bootstrap Padding Fix --*/ 63[class*="col-"] { 64 padding: 1rem; 65} 66 67 68 69 70 71/* 72Extra small (xs) devices (portrait phones, less than 576px) 73No media query since this is the default in Bootstrap 74 75Small (sm) devices (landscape phones, 576px and up) 76@media (min-width: 576px) { ... } 77 78Medium (md) devices (tablets, 768px and up) 79@media (min-width: 768px) { ... } 80 81Large (lg) devices (desktops, 992px and up) 82@media (min-width: 992px) { ... } 83 84Extra (xl) large devices (large desktops, 1200px and up) 85@media (min-width: 1200px) { ... } 86*/ 87 88 89 90 91 92 93 94 95
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/17 14:02