简体   繁体   English

Bootstrap 4 - 导航栏不会折叠

[英]Bootstrap 4 - Navbar won't collapse

I have no idea why it isn't working.我不知道为什么它不起作用。 I even tried to copy and paste the button and div tags from the examples in bootstrap's web site.我什至尝试从引导程序网站的示例中复制和粘贴按钮和 div 标签。 I thought it has something to with the social media icons part.我认为它与社交媒体图标部分有关。 I turned them into comment lines but didn't work.我把它们变成了注释行,但没有用。 Do you see my mistake?你看到我的错误了吗?

Sorry if this is a repeat.对不起,如果这是重复。 I found questions with same title but they didn't help.我发现了具有相同标题的问题,但它们没有帮助。

Thanks...谢谢...

 <!doctype html> <html lang="tr"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <title>This is a page</title> </head> <body> <nav class="navbar navbar-expand bg-faded" style="background-color: #233042;"> <div class="container"> <img class="navbar-brand" width="130" src="http://via.placeholder.com/200x50"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#menu"> <i class="fas fa-bars"></i> </button> <div class="collapse navbar-collapse" id="menu"> <ul class="navbar-nav mx-auto"> <li class="nav-item"> <a class="nav-link text-light" href="#">Anasayfa</a> </li> <li class="nav-item"> <a class="nav-link text-light" href="#">Ürünlerimiz</a> </li> <li class="nav-item"> <a class="nav-link text-light" href="#">Hizmetlerimiz</a> </li> <li class="nav-item"> <a class="nav-link text-light" href="#">Hakkımızda</a> </li> </ul> </div> <ul class="navbar-nav justify-content-end"> <li class="nav-item"> <a class="nav-link text-light" href="#" target="_blank"><i class="fab fa-twitter fa-lg"></i></a> </li> <li class="nav-item"> <a class=" nav-link text-light" href="#" target="_blank"><i class="fab fa-facebook-f fa-lg"></i></a> </li> <li class="nav-item"> <a class=" nav-link text-light" href="#" target="_blank"><i class="fab fa-instagram fa-lg"></i></a> </li> </ul> </div> </nav> <!-- Optional JavaScript --> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script> </body> </html>

You are using the class navbar-expand , which means that it never collapses.您正在使用类navbar-expand ,这意味着它永远不会折叠。 Just change it to navbar-expand-sm , and it will collapse on small screens.只需将其更改为navbar-expand-sm ,它就会在小屏幕上折叠。

Check the docs for more info.查看文档以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM