My current theme looks like this: https://gyazo.com/70ebe1ff52847bfbd7220f8e9bbe4854
But when i insert the bootstrap cdn I get: https://gyazo.com/1d97573cc6765ee55f99d99b5094f0cc
I check the css using chrome but I don't understand what changed when I got bootstrap. My navbar got larger and has a black line under the navbar. How can I know what's causing this and how can I remove it? Thank you.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/style.css"/>
<!--Navbar-->
<nav class="navbar bg-primary-gradient col-lg-12 col-12 p-0 fixed-top navbar-inverse d-flex flex-row">
<div class="bg-white text-center navbar-brand-wrapper">
<a class="navbar-brand brand-logo" href="#"><img src="images/logo_star_black.png"/></a>
<a class="navbar-brand brand-logo-mini" href="#"><img src="images/logo_star_mini.jpg" alt=""></a>
</div>
<div class="navbar-menu-wrapper d-flex align-items-center">
<button class="navbar-toggler navbar-toggler hidden-md-down align-self-center mr-3" type="button"
data-toggle="minimize">
<span class="navbar-toggler-icon"></span>
</button>
<form class="form-inline mt-2 mt-md-0 hidden-md-down">
<input class="form-control mr-sm-2 search" type="text" placeholder="Search">
</form>
<ul class="navbar-nav ml-lg-auto d-flex align-items-center flex-row">
<li class="nav-item">
<a class="nav-link profile-pic" href="#"><img class="rounded-circle" src="images/face.jpg"
alt=""></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fa fa-th"></i></a>
</li>
</ul>
<button class="navbar-toggler navbar-toggler-right hidden-lg-up align-self-center" type="button"
data-toggle="offcanvas">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<!--End navbar-->
Add css
.navbar-inverse
{
border: none !Important;
}
Related
I want to change this bootstrap5 navbar buttons from left side to a right side, but I don't know how to do that using css or bootstrap5, guys how can I do this?
My Code:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">
<h1>Pondadb</h1>
</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="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">About</a>
</li>
<li class="nav-item">
<a class="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">Contact</a>
</li>
<li class="nav-item">
<a class="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">Login</a>
</li>
<li class="nav-item">
<a class="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">Singn-Up</a>
</li>
</ul>
</div>
</div>
</nav>
You have .mr-auto which is Bootstrap 4's version of margin-right: auto;. This does not work in B5 and the correct class would be .me-auto.
However, you don't want margin-right: auto;, you want margin-left: auto; to push the elements to the right. In B5, you should use ms-auto.
Spacing ยท Bootstrap v5.3
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">
<h1>Pondadb</h1>
</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 ms-auto">
<li class="nav-item active">
<a class="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">About</a>
</li>
<li class="nav-item">
<a class="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">Contact</a>
</li>
<li class="nav-item">
<a class="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">Login</a>
</li>
<li class="nav-item">
<a class="btn btn-primary mx-lg-2 mx-0 my-lg-0 my-2" href="#">Singn-Up</a>
</li>
</ul>
</div>
</div>
</nav>
I think changing of "mr-auto" in into "ml-auto" should help. It is bootstrap form of margin-right: auto, so it means that it is positioned at right. If I undertand you right, you want it to be on right side, so change it to margin-left: auto = ml-auto.
I am using Bootstrap 5 within Rails 7 application. I am following Bootstrap's Dashboard example https://getbootstrap.com/docs/5.0/examples/dashboard/ but within my Rails application the navbar-toggler-icon is not displaying (nor does it work) when I shorten the width of the browser window.
I have a CodePen example https://codepen.io/chrisgo-cp/pen/zYPpEPp that shows the code I am using and navbar-toggler-icon is not displaying.
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3" href="#">Company name</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button"
data-bs-toggle="collapse" data-bs-target="#sidebarMenu"
aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<a class="nav-link px-3" href="#">Sign out</a>
</div>
</div>
</header>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">
<!-- <span data-feather="home"></span> -->
Link ?
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<!-- <span data-feather="file"></span> -->
Link ?
</a>
</li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Saved reports</span>
<a class="link-secondary" href="#" aria-label="Add a new report">
<!-- <span data-feather="plus-circle"></span> -->
</a>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item">
<a class="nav-link" href="#">
<!-- <span data-feather="file-text"></span> -->
Report 1
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<!-- <span data-feather="file-text"></span> -->
Report 2
</a>
</li>
</ul>
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<%= yield %>
</main>
</div> <!--/ .row -->
</div> <!--/ .container-fluid -->
Here you go... Remove position-absolute from the <button>.
<!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 rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css' integrity='sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU' crossorigin='anonymous'>
<script src='https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/js/bootstrap.min.js' integrity='sha384-skAcpIdS7UcVUC05LJ9Dxay8AXcDYfBJqt1CJ85S/CFujBsIzCIv+l9liuYLaMQ/' crossorigin='anonymous'></script>
</head>
<body>
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3" href="#">Company name</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<button class="navbar-toggler d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<a class="nav-link px-3" href="#">Sign out</a>
</div>
</div>
</header>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">
<!-- <span data-feather="home"></span> -->
Link ?
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<!-- <span data-feather="file"></span> -->
Link ?
</a>
</li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Saved reports</span>
<a class="link-secondary" href="#" aria-label="Add a new report">
<!-- <span data-feather="plus-circle"></span> -->
</a>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item">
<a class="nav-link" href="#">
<!-- <span data-feather="file-text"></span> -->
Report 1
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<!-- <span data-feather="file-text"></span> -->
Report 2
</a>
</li>
</ul>
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<%= yield %>
</main>
</div>
<!--/ .row -->
</div>
<!--/ .container-fluid -->
</body>
</html>
I have the following code:
<div class="container-fluid big-logo bg-light" id="big-logo">
<nav class="navbar nav-pills flex-column justify-content-center flex-sm-row navbar-expand-lg navbar-light bg-white">
<a href="{% url 'home' %}" class="nav-item">
<img alt="logo" src="{% static 'img/fuck.jpg' %}" style="max-height:40px;">
</a>
<a href="{% url 'cart' %}" class="nav-item">
<div>
<img alt="cart" class="card-title" src="{% static 'img/cart.png' %}" style="max-height:30px;">
<span class='badge badge-warning' id='lblCartCount'> {{ obj }} </span>
<h6 class="card-subtitle text-muted">Cart</h6>
</div>
</a>
</nav>
</div>
This is how the current and the expected results:
I have tried many options but nothing can be done. How can I do to get the expected result?
Use and m-auto and ml-auto class on the anchor tag to align it to right. Remove justify-content-center from nav:
<div class="container-fluid big-logo bg-light" id="big-logo">
<nav class="navbar nav-pills flex-column flex-sm-row navbar-expand-lg navbar-light bg-white">
<a href="{% url 'home' %}" class="nav-item m-auto">
<img alt="logo" src="{% static 'img/fuck.jpg' %}" style="max-height:40px;">
</a>
<a href="{% url 'cart' %}" class="nav-item ml-auto">
<div>
<img alt="cart" class="card-title" src="{% static 'img/cart.png' %}" style="max-height:30px;">
<span class='badge badge-warning' id='lblCartCount'> {{ obj }} </span>
<h6 class="card-subtitle text-muted">Cart</h6>
</div>
</a>
</nav>
</div>
Use mx-md-auto, example navbar: (run code on full page)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<nav class="navbar navbar-expand-md navbar-fixed-top navbar-dark bg-dark main-nav">
<div class="container">
<div class="navbar-collapse collapse nav-content order-2">
<ul class="nav navbar-nav">
</ul>
</div>
<ul class="nav navbar-nav text-nowrap flex-row mx-md-auto order-1 order-md-2">
<li class="nav-item"><a class="nav-link" href="#">Center</a></li>
<button class="navbar-toggler ml-2" type="button" data-toggle="collapse" data-target=".nav-content" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</ul>
<div class="ml-auto navbar-collapse collapse nav-content order-3 order-md-3">
<ul class="ml-auto nav navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Right</a>
</li>
</ul>
</div>
</div>
</nav>
I try to make a website in Boostrap 4, but I faced into a problem. I try to explain what I need.
A fixed to top navbar with 2 rows, but here comes the trick. Upper bar contains 2 logos (one on the left side and one on the right side, in the same row.
The second row contains only links, but ordered to center. Hopefully, my description not so misunderstandible.
Thanks for your help!
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">Fixed navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<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="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<nav class="navbar fixed-top navbar-light bg-light">
<div class="row d-flex w-100 justify-content-between" >
<img class="" style="width: 3rem" src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Bootstrap_logo.svg/1024px-Bootstrap_logo.svg.png" />
<img class="" style="width: 3rem" src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Bootstrap_logo.svg/1024px-Bootstrap_logo.svg.png" />
</div>
<div class="row w-100 ">
<ul class="d-flex list-unstyled mx-auto w-25 justify-content-between">
<li class="">My links </li>
<li class="">My links </li>
<li class="">My links </li>
</ul>
</div></nav>
Is it what you are looking for?
I am using 'Album' example from Bootstrap 4.1 and unable to get the extra nav-items to display horizontally.
I tried to add 'navbar-expand-lg', and it brings all to horizontal line. But, the toggler-button (and hence its header data) vanishes and becomes inaccessible.
Code as below;
<script src="http://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<header>
<!-- Navbar#1 Toggled - Detailed Header Info-->
<div class="collapse bg-dark" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">Lines of Data Shortened.</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li>Follow on Twitter</li>
<li>Like on Facebook</li>
<li>Email me</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Navbar#2 Permanent Strip of Navbar -->
<div class="navbar navbar-dark bg-dark shadow-sm">
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<!-- SVG Album Icon -->
<strong>Album</strong>
</a>
<!-- Nav Items Manually added -->
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Features</a>
<a class="nav-item nav-link" href="#">Pricing</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</div>
<!-- Navbar#3 - Visible Toggle Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</header>
Add float: left;CSS to your li items.
Also you can try this
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_navbar&stacked=h
I got the answer.
The navbar was a flexbox with 'd-flex'. So, I added a 'flex-row', which brings nav-items horizontally. 'mr-auto' brings margin properly.
<script src="http://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<header>
<!-- Navbar#1 Toggled - Detailed Header Info-->
<div class="collapse bg-dark" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">Lines of Data Shortened.</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li>Follow on Twitter</li>
<li>Like on Facebook</li>
<li>Email me</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Navbar#2 Permanent Strip of Navbar -->
<div class="navbar navbar-dark bg-dark shadow-sm">
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<!-- SVG Album Icon -->
<strong>Album</strong>
</a>
<!-- Nav Items Manually added -->
<div class="navbar-nav flex-row mr-auto">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Features</a>
<a class="nav-item nav-link" href="#">Pricing</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</div>
<!-- Navbar#3 - Visible Toggle Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</header>