Bootstrap 4: Struggeling with the responisve navbar element - html

to rework an old webpage, based on Bootstrap 3, I tried to build up a new page from scratch with Bootstrap 4. I started with the navbar element, which should be always shown on top, have a brand logo and the left and some page links on the right - in priniciple not special, but I didn't manage it.
I reduced my wishes more and more and I want solve the problem, I have with the toggling between icon menu and links.
I am only able to get the icon menu button always visible (without "collapse" in button class), also for large screens, or never visible (with "collapse" in button class). The rest of the code should be nearly standard as read in many many examples and tutorials. Could you please have a hint, what is it running wrong?
Thanks in advance,
Ralf
Updated:
I investigate with the Inspector and the it seems the navbar toogle button is there, but completely transparent!? Is this my problem and I have to define a color to this button (it works in principle with background-color, but I missed the lines inside) or could this a problem with Javascript and the switching function?
Here is the code - should be standard (all cosmetics are doesn't matter, I will care about later with css).
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Testseite</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-default bg-light navbar-fixed-top py-lg-0">
<div class="container-fluid">
<img src="./img/smile.png" width="60" height="60" alt="Logobeschreibung">
<button type="button" class="navbar-toggle collapse" data-toggle="collapse" data-target="#navbarResponsive" aria-expanded="false" aria-label="Toogle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse" id="navbarResponsive">
<ul class="navbar-nav">
<li class="nav-item active">Startseite<span class="sr-only">(current)</span>
</li>
<li class="nav-item"><a class="nav-link" href="#">Seite1</a></li>
<li class="nav-item"><a class="nav-link" href="#">Seite2</a></li>
<li class="nav-item"><a class="nav-link" href="#">Seite3</a></li>
</ul>
</div>
</div>
</nav>
<!-- Menu -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj " crossorigin="anonymous "></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx " crossorigin="anonymous "></script>
</body>
</html>

I am assuming you want to always see this block of Bootstrap always shown in your header, correct?
<button type="button" class="navbar-toggle collapse" data-toggle="collapse" data-target="#navbarResponsive" aria-expanded="false" aria-label="Toogle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon"></span>
</button>
Because Bootstrap controls its appearance based on the viewport width using media queries, a simple hack to force it to always show would be the following. Add this to your style sheet:
.navbar-toggle {
display:inline-block !important;
}
I am not a fan of Bootstrap navigation for this reason and many more. It just feels incomplete and difficult to customize with CSS.

Can you please check the below code? Hope it will work for you. You need to use navbar-toggler class in toggle button instead of navbar-toggle as per bootstrap documentation. We have given background in navbar-toggler because you used navbar bg-light class.
Please refer to this link:
https://jsfiddle.net/yudizsolutions/3vmuec5g/10/
.navbar .navbar-toggler {
background: #0000ff;
}
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Testseite</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-default bg-light navbar-fixed-top py-lg-0">
<div class="container-fluid">
<img src="./img/smile.png" width="60" height="60" alt="Logobeschreibung">
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toogle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse" id="navbarResponsive">
<ul class="navbar-nav">
<li class="nav-item active">Startseite<span class="sr-only">(current)</span>
</li>
<li class="nav-item"><a class="nav-link" href="#">Seite1</a></li>
<li class="nav-item"><a class="nav-link" href="#">Seite2</a></li>
<li class="nav-item"><a class="nav-link" href="#">Seite3</a></li>
</ul>
</div>
</div>
</nav>
<!-- Menu -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj " crossorigin="anonymous "></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx " crossorigin="anonymous "></script>
</body>
</html>

Related

navbar doesn't show correctly

I am currently teaching myself web based languages and I am a bit stuck on my bootstrap/html code. Currently I am running into some trouble with bootstrap. I am trying to make a navbar and I have copied code I found online and pasted on Atom and then ran the local site.
Here is the code
<!DOCTYPE html>
<html lang="en">
<head>
<title>testing</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Collapse button -->
<button class="navbar-toggler toggler-example" type="button" data-toggle="collapse" data-target="#navbarSupportedContent1"
aria-controls="navbarSupportedContent1" aria-expanded="false" aria-label="Toggle navigation"><span class="dark-blue-text"><i
class="fas fa-bars fa-1x"></i></span></button>
<!-- Collapsible content -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Links -->
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="\Users\sealc\.atom\Web Dev\testing\pagethree.html">page three</a>
</li>
<li class="nav-item">
<a class="nav-link" href="C:\Users\sealc\.atom\Web Dev\testing\pagetwo.html">Page two</a>
</li>
<li class="nav-item">
<a class="nav-link" href="C:\Users\sealc\.atom\Web Dev\testing\pagefour.html">Page four</a>
</li>
</ul>
<!-- Links -->
</div>
<!-- Collapsible content -->
</nav>
</body>
</html>
it works when I fiddle with it on codeply, but when I try to run the local site I keep getting this:navbar
It is probably an easy fix, but I am no expert, I already tried using different links for bootstrap an I copied the template on their website, but nothing changed
I tested your code on my environment the link might not work. I changed the link and it worked again. Here it is:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
Check the conflict something like:
How many .JSFile Version you are using?
If you have A master page i guess that is the cause. (Cause by the other pages)
To Resolve:
Try to comment some other .JS and run to check the cause.
May check also your .CSS using inspect element.
By Forcing the style you want or to By pass the old css, you can add in your style !important to the affected area.
Like for Example:
<style>
.sampleclass{
color: red !important
}
</style>
Hello #Jacob Dubois I have check your code. Your code is perfect but bootstrap css has a problems. Please use this bootstrap latest version. For Example :=> https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css

"connect" dropdown box and input form in bootstrap

So I have the HTML below. If you click on the search (in the top right), you'll see a dropdown box appear in the top left. I want to "connect" these, so that the dropdown box is properly below the search box and the whole thing behaves like how a button connected to a dropdown would.
I'm not really a web guy and I don't really "know" Bootstrap (this is my first time using it) so please bear that in mind!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" href="/static/css/style.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js"></script>
<script src="https://use.fontawesome.com/6e0448e881.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0" method="get">
<input name="q" id="qbox" data-toggle="dropdown" type="search" class="form-control" placeholder="Search" autofocus="autofocus" autocomplete="off"/>
<div id="search_results" class="dropdown-menu" role="menu">
<div>a</div>
<div>b</div>
<div>c</div>
</div>
</form>
</div>
</nav>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
</body>
</html>
You have to override the class applied to the dropdown menu, which is called .dropdown-menu.
In your css:
.dropdown-menu{
left: initial;
}
Depending on how your css structure looks you may call this rule with an !important behind the inital statement.

Bootstrap navbar-toggler-icon not visible but functioning normally [duplicate]

This question already has an answer here:
Bootstrap navbar: nothing is displayed on smaller devices
(1 answer)
Closed 2 years ago.
I am trying to get my bootstrap navbar implemented into my handlebars layout file. I've noticed some weird things happening with bootstrap and this is no exception. Once I shrink my window to a size where the navbar-toggler-icon should show, it is not visible, but it is still functioning there like it should, I just can't see it.
Here is my entire layout.hbs class:
<!DOCTYPE html>
<html lang="en">
<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-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>
<nav id="navigation" class="navbar navbar-inverse">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
</div>
</nav>
{{{body}}}
<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.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</body>
</html>
Here is an example of whats happening:
Picture of whats happening
I was told changing my navbar class to navbar-inverse would make it appear but I had no luck with this either.
Try using navbar navbar-light instead of navbar navbar-inverse.
Bootstrap 4 is a major rewrite of the older Bootstrap and this was changed
Bootstrap Migration guide
For Bootstrap 4:
change your bootstrap class on this line <nav id="navigation" class="navbar navbar-inverse"> as shown below:
<nav id="navigation" class="navbar navbar-dark bg-dark">

Hamburger and drop down not showing in mobile with Bootstrap navbar

I've been searching the boards here and nothing seems to cover what could be wrong. My navbar is all well and good but no hamburger or menu shows up when I go mobile. I've tried changing combinations and implementing different collapse names, but to no avail. Any ideas? Here's my code:
<header class="navbar navbar-custom" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<nav class="collapse navbar-collapse" role="navigation">
<ul class="nav navbar-nav pages">
<li class="page">item1</li>
<li class="page">item2</li>
<li class="page">item3</li>
<li class="page hidden-xs"><img id="nav-brand" src="images/nav-logo1.png" width="120" alt="logo description"></li>
<li class="page">item4</li>
<li class="page">item5</li>
<li class="page">item6</li>
</ul>
</div>
</div>
</header>
Check if you have the meta tag in your head section
<meta name="viewport" content="width=device-width, initial-scale=1">
Also your Nav tag is not closing after the ul element. Check your tag closures
I think the </div> after the </ul> has to be replaced
In the original code, there's a div that closes the nav. That happened when I formatted for this site. In the original, it is closed by a nav tag. I forgot to include the header sets. Here they are:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<link rel='shortcut icon' href='images/favicon.ico' type='image/x-icon'/ >
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">
<link rel="stylesheet" href="css/styles.css">
<script src="js/main.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css?family=Oswald:300,400,700" rel="stylesheet">
<script src="https://use.fontawesome.com/8633c13aa3.js"></script>
</head>
you should check the horizontal scroll when u minimize the screen.that is one of the reason when your content in not fully responsive and when u minimize the screen the scroll appears horizontally and the hamburger icon not appear...
first of all remove all content expect the navigation on your page and then minimize the screen .and if problem still appers then you sould also check that your background color and color are change or not..

Why can I not see any content? [duplicate]

This question already has answers here:
twitter bootstrap navbar fixed top overlapping site
(19 answers)
Closed 6 years ago.
Can anybody tell me why I can not see the text under my navbar. Is it hiding it? I have set the navbar as fixed. Is this the issue?
I am trying to add a header underneath but I can't even see the text.
Thanks in advance
Reece
<!DOCTYPE html>
<html>
<head>
<!-- LINKS TO EXTERNAL FILES (BELOW) -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="slyderesp.css">
<title></title>
</head>
<body>
<!-- NAVBAR (RESPONSIVE) -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Slyde</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Meet The Band</li>
<li>Photos</li>
<li>Videos</li>
<li>Contact</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<!--HEADER (RESPONSIVE)-->
<div>WHY CANT I SEE THIS?</div>
<!--LINK TO EXTERNAL FILES (BELOW) -->
<script type="text/javaScript" src="js/slyderesp.js"></script>
<script src="js/jquery-3.1.0.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
Your navbar has the class .navbar-fixed-top which makes it fixed in the browser window. Your <div> is just below it. Remove that class or add some padding to your body.