Home > Blockchain >  Navbar Won't collapse on mobile version
Navbar Won't collapse on mobile version

Time:12-09

Navbar doesn't drop down and show the options on the mobile version. I am trying to figure out how to get it to work, but no luck.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>COS Gym</title>
<link href="cos-gym.css" rel="stylesheet" type= "text/css" />
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<header >
<div >
  <nav font-size="120%" margin-left="30%" margin-top="8%" >
    <a href="#" text-decoration="none" padding="4%" >
      <div >
        <img src="images/logo_gym.png">
      </div>
    </a>
    <button  type="button" data-bs-toggle="collapse" data-bs-target="#toggleMobileMenu" aria-controls="toggleMobileMenu" aria-expanded="false" aria-label="Toggle navigation">
      <span ></span>
    </button>
    <div  id="#toggleMobileMenu">
      <ul >
        <li ><a  aria-current="page" href="index.html">Home</a></li>
        <li ><a  aria-current="page" href="about.html">About</a></li>
        <li ><a  aria-current="page" href="schedule.html">Schedule</a></li>
        <li ><a  aria-current="page" href="online.html">Online</a></li>
        <li ><a  aria-current="page" href="shop.html">Shop</a></li>
        <li ><a  aria-current="page" href="contact.html">Contact</a></li>
      </ul>
    </div>
 </nav>
</div> 
</header>
<main>
<div >
  <img src="images/home.jpg">
  <div ><h>COS GYM</h>
  <a href="login.html"><button >Log in</button></a>
  <a href="registration.html"><button >Sign up</button></a></div>
<div >
<figure>
  <img src="images/main1.jpg">
<figcaption >Zumba Dance</figcaption>
</figure>
<figure>
<img src="images/main2.jpg">
<figcaption >Power Training</figcaption>
</figure>
<figure>
<img src="images/main3.jpg">
<figcaption >Yoga Fitness</figcaption>
</figure>
</div>
</main>
<footer>
  <div>
    <ul>
     <dt>Email Us</dt>
     <dt>[email protected]</dt>
    </ul>
  </div>
   <div>
     <h3>Welcome to ChrisOlySim Gym</h3>
     <h4>Contact Us 989-888-9999</h4>
   </div>
   <div>
    <ul>
     <dt>Follow Us</dt>
     <dt><i ></i>
      <i ></i>
      <i ></i>
    </dt>
    </ul>
    </div>
    </footer>
    <script src="https://kit.fontawesome.com/42ca52e1de.js" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg OMhuP IlRH9sENBO0LRn5q 8nbTov4 1p" crossorigin="anonymous"></script>
  </body>
</html>

Also ms-auto doesn't seem to work either, and when I try to change the size of the text, it refuses to grow past a certain point. Can I get help please? I've tried switching the order of the scripts that run, I've tried running it with JQuery, I've tried everything. The only time I see the options is when I use the container-fluid class, but since I can't hide the options when I do that on the mobile version, there's no point. How do I get this to work?

CodePudding user response:

It is because you are still using classes from BS4. Try reading the docs of BS5 here.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
    <nav >
        <div >
            <a  href="#">Navbar</a>
            <button  type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
                <span ></span>
            </button>
            <div  id="navbarNavAltMarkup">
                <div >
                    <a  aria-current="page" href="#">Home</a>
                    <a  href="#">Features</a>
                    <a  href="#">Pricing</a>
                    <a  href="#" tabindex="-1" aria-disabled="true">Disabled</a>
                </div>
            </div>
        </div>
    </nav>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>

  • Related