artemoo
January 20, 2023, 12:34pm
1
Hi there,
I am doing the codecademy bootstrap project “adhoc”. For some reason my navbar button won’t display the links when collapsed. I would appreciate your help. Here’s my code.
<body>
<nav class="navbar navbar-light navbar-expand-md bg-light">
<a class="navbar-brand"><img
src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/logo.png?_gl=1*1oqdye0*_ga*NDYyMjI2MzA5Ny4xNjcyNTg2NDMw*_ga_3LRZM6TM9L*MTY3NDIwNzkyNC40MS4xLjE2NzQyMTA1NjAuMC4wLjA."
alt="AdHoc Logo" height="30">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav px-2">
<li class="nav-item px-2 "><a class="nav-link" href="#"></a>Home</a></li>
<li class="nav-item px-2 "><a class="nav-link" href="#"></a>About Us</a></li>
<li class="nav-item px-2 "><a class="nav-link" href="#"></a>Our Team</a></li>
<li class="nav-item px-2 "><a class="nav-link" href="#"></a>Contact Us</a></li>
</ul>
</div>
</nav>
</body>
But isn’t that the purpose of it? That everything inside the collapse container becomes invisible when collapsed?
Can you provide a link to the exercise?
thank you for your reply
you can find the exercise here: https://www.codecademy.com/courses/learn-bootstrap/projects/adhoc-bootstrap
and my github project here: adHoc
what i meant to say was that the links are not displayed in smaller screens
From the Bootstrap docs:
Navbars require a wrapping .navbar
with .navbar-expand{-sm|-md|-lg|-xl|-xxl}
for responsive collapsing and color scheme classes.
So try navbar-expand-sm rather than navbar-expand-md.
If you are using bootstrap 5, try changing the data-toggle and data-target like this (adding bs in between the dashes):
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
The reason is that they changed it on the latest version. Give it a try and let me know.
Cheers!
ricardo-719:
data-bs-toggle
thanx for your reply
unfortunately that didn’t work
the funny thing is that when i copy paste my code from visual studio to the codecademy editor it works fine. so i reckon it must be sth else maybe sth between the tags
<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">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="..//adhoc/resources/css/style.css">
<title>adHoc</title>
</head>
artemoo:
collapsibleNavbar
Try adding Bootstrap’s JS scripts right before the body closing tag. Below all your code.
You can find it here
This one:
system
Closed
March 3, 2023, 4:51pm
8
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.