2
 <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <img src="http://karinakozarova.me/Blog/pics/logo-kari.png" width = "90px"/> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav navbar-right text-color"> <li><a class = "menu" href="\Blog\home.html">Home</a></li> <li><a class = "menu" href="\Blog\posts.html">Posts</a></li> <li><a class = "menu" href="\Blog\contact_info.html">Contact</a></li> <li><a class = "menu" href="\Blog\about.html">About</a></li> </ul> </div> </div> </nav> 

The following code doesn't work on mobile, in another SO question I read that the data-target="myNavbar" so i did it but it's still not working.

4
  • Do you use the script too? Commented Jul 16, 2017 at 12:40
  • Which script do you mean? Commented Jul 16, 2017 at 12:52
  • 1
    The bootstrap javascript which handle this of course :) I see, the problem was solved. What was the problem? Commented Jul 17, 2017 at 5:29
  • 1
    Forgotten jquerry link Commented Jul 17, 2017 at 19:12

1 Answer 1

2

you are giving data-target an ID ...You need to use # before the id

set

data-target="#myNavbar" 

It should work now.

<html lang="en"> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <img src="http://karinakozarova.me/Blog/pics/logo-kari.png" width = "90px"/> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav navbar-right text-color"> <li><a class = "menu" href="\Blog\home.html">Home</a></li> <li><a class = "menu" href="\Blog\posts.html">Posts</a></li> <li><a class = "menu" href="\Blog\contact_info.html">Contact</a></li> <li><a class = "menu" href="\Blog\about.html">About</a></li> </ul> </div> </div> </nav> </body> </html>

Sign up to request clarification or add additional context in comments.

4 Comments

Its working...make sure you have added css from bootstrap and script from jquery before script from bootstrap and if still not working do tell me i'll link the codepen
Can you please share it?
check out the snippet
glad to be of help:-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.