I'm trying to collapse the Bootstrap navbar when the screen width is 1280px but instead of getting the navbar collapsed, the Navbar goes on top, this is my code:
body {
padding-top: 90px;
}
#media (min-width: 1280px) {
body {
padding-top: 0;
}
}
#media (min-width: 1280px) {
body {
margin-left: 232px;
}
}
.navbar.fixed-left {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1030;
}
#media (min-width: 1280px) {
.navbar.fixed-left {
bottom: 0;
width: 232px;
flex-flow: column nowrap;
align-items: flex-start;
}
.navbar.fixed-left .navbar-collapse {
flex-grow: 0;
flex-direction: column;
width: 100%;
}
.navbar.fixed-left .navbar-collapse .navbar-nav {
flex-direction: column;
width: 100%;
}
.navbar.fixed-left .navbar-collapse .navbar-nav .nav-item {
width: 100%;
}
.navbar.fixed-left .navbar-collapse .navbar-nav .nav-item .dropdown-menu {
top: 0;
}
}
#media (min-width: 1280px) {
.navbar.fixed-left {
right: auto;
}
.navbar.fixed-left .navbar-nav .nav-item .dropdown-toggle:after {
border-top: 0.3em solid transparent;
border-left: 0.3em solid;
border-bottom: 0.3em solid transparent;
border-right: none;
vertical-align: baseline;
}
.navbar.fixed-left .navbar-nav .nav-item .dropdown-menu {
left: 100%;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet"
id="theme_link"
href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.3.1/materia/bootstrap.min.css"/>
<nav class="navbar navbar-expand-md navbar-dark bg-primary fixed-left">
<a class="navbar-brand" href>Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link">Home</a>
</li>
<li class="nav-item">
<a class="nav-link">About</a>
</li>
<li class="nav-item">
<a class="nav-link">Contact</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu">
<a class="dropdown-item">Action</a>
<a class="dropdown-item">Another action</a>
<a class="dropdown-item">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item">Separated link</a>
<a class="dropdown-item">One more separated link</a>
</div>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-class="fixed-left">
<i class="fa fa-arrow-left"></i>
Fixed Left
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-class="fixed-top">
<i class="fa fa-arrow-up"></i>
Fixed Top
<small>(original)</small>
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-class="fixed-right">
<i class="fa fa-arrow-right"></i>
Fixed Right
</a>
</li>
</ul>
</div>
</nav>
<div class="container">
<div class="jumbotron">
<h1 class="display-4">
Bootstrap Navbar Sidebar
<br>
<small>Fixed to Left or Right</small>
</h1>
<p>
<strong>
Use classic Bootstrap navbar as sidebar, on left or right side.
</strong>
</p>
<p>
<a class="github-button" href="https://github.com/mladenplavsic/bootstrap-navbar-sidebar"
data-icon="octicon-star" data-show-count="true"
aria-label="Star mladenplavsic/bootstrap-navbar-sidebar on GitHub">Star</a>
<a class="github-button" href="https://github.com/mladenplavsic/bootstrap-navbar-sidebar/fork"
data-icon="octicon-repo-forked" data-show-count="true"
aria-label="Fork mladenplavsic/bootstrap-navbar-sidebar on GitHub">Fork</a>
<a class="github-button" href="https://github.com/mladenplavsic"
aria-label="Follow #mladenplavsic on GitHub">Follow #mladenplavsic</a>
</p>
<p>Same as when using <code>.fixed-top</code> for navbar - add class <code>.fixed-left</code> or <code>.fixed-right</code>
where needed.</p>
<p>Click buttons below, and appropriate class will be added to example navbar.</p>
<div class="btn-group" role="group">
<button type="button" data-class="fixed-left" class="btn btn-primary">
<i class="fa fa-arrow-left"></i>
Fixed Left
</button>
<button type="button" data-class="fixed-top" class="btn btn-primary">
<i class="fa fa-arrow-up"></i>
Fixed Top
<small>(original)</small>
</button>
<button type="button" data-class="fixed-right" class="btn btn-primary">
<i class="fa fa-arrow-right"></i>
Fixed Right
</button>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group">
<label>
Select another bootstrap theme from
Bootswatch
</label>
<select class="form-control width-md" id="theme_select" onchange="selectTheme(value)"></select>
</div>
</div>
</div>
</div>
As you can see I setted 1280px in the media queries, but for some reason the navbar instead of collapse, is displayed as topbar, what I did wrong?
Bootstrap's closest breakpoint is at 1200px. I'd recommend sticking to it, because that way you avoid excessive layout changes. If you're willing to move your breakpoints to #media 1200px to match Bootstrap, you can simply change your class .navbar-expand-md to .navbar-expand-xl, and that's it.
Codepen: https://codepen.io/Terrafire123/pen/NWRKdKR
Edit:
If all you want to do is simply prevent the sidebar from overlapping the body, you can add this:
#media (min-width: 1200px) {
body {
margin-left: 232px !important;
}
}
(This already exists in your original code, but without !important, it's getting overwritten to margin:0; by Bootstrap's default settings.)
Related
am trying to making a simple UI in their I stuck, I want full width my input type but its showing short, can anyone tell me how can I make full it, and also I want responsive in mobile and desktop mode
Navbar.js
This is the navbar.js file where I wrote my UI part
import React from 'react'
import './Navbar.css';
import SearchOutlinedIcon from '#material-ui/icons/SearchOutlined';
const Navbar = () => {
return (
<nav class="navbar navbar-expand-lg navbar-light bg-light shadow-sm p-3 bg-white ">
<div className="container">
<a class="navbar-brand" href=""><img src="https://imgeng.jagran.com/images/2021/jan/Myntra-805x530-1-700x4611611985286383.jpg" alt="Mynta" className="coco mr-5" /></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 ">
<a class="nav-link mr-2" href="#">MEN</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">WOMEN</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">KIDS</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">HOME & LIVING</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">OFFERS</a>
</li>
</ul>
{/* <div className='sidebar_search'>
<div className='sidebar_searchContainer'>
<SearchOutlinedIcon />
<input type='text' placeholder='Search for products brands and more' />
</div>
</div> */}
<div class="form-group has-search">
<span class="fa fa-search form-control-feedback"></span>
<input type="text" class="form-control" placeholder="Search for Products Branda and More" />
</div>
</div>
</div>
</nav>
)
}
export default Navbar;
style.css
This is the style.css file where I wrote some css
#media (min-width: 1200px) {
.container{
max-width: 1400px;
}
}
.coco{
width: 60px;
}
.nav-item{
font-weight: bold;
color: black;
}
.nav-item, .nav-link {
font-size: 17px;
color: black;
}
.has-search .form-control {
padding-left: 2.375rem;
}
.has-search .form-control-feedback {
position: absolute;
z-index: 2;
display: block;
width: 2.375rem;
height: 2.375rem;
line-height: 2.375rem;
text-align: center;
pointer-events: none;
color: #aaa;
}
input[type="text"] {
outline: none;
box-shadow:none !important;
border:1px solid #ccc !important;
}
/* .sidebar_search{
display: flex;
align-items: center;
height: 39px;
padding: 10px;
background-color: #f0f0f0;
margin-right: 100px;
width: 100%;
}
.sidebar_searchContainer > input {
border: none;
margin-left: 10px;
outline: none;
background-color:#f0f0f0;
} */
you could try this code:
CSS (not big changes)
#media (min-width: 1200px) {
.container{
max-width: 1400px;
}
}
.coco{
width: 60px;
/*border: 1px solid blue;*/
}
.nav-item{
font-weight: bold;
color: black;
}
.nav-item, .nav-link {
font-size: 17px;
color: black;
}
.has-search .form-control {
padding-left: 2.375rem;
}
.has-search .form-control-feedback {
position: absolute;
z-index: 2;
display: block;
width: 2.375rem;
height: 2.375rem;
line-height: 2.375rem;
text-align: center;
pointer-events: none;
color: #aaa;
}
input[type="text"] {
outline: none;
box-shadow:none !important;
border:1px solid #ccc !important;
}
HTML (some changes)
<div class="container-fluid">
<nav class="navbar navbar-expand-lg navbar-light bg-light shadow-sm p-3 bg-white ">
<a class="navbar-brand" href="">
<img src="https://imgeng.jagran.com/images/2021/jan/Myntra-805x530-1-700x4611611985286383.jpg" alt="Mynta" class="coco mr-5" />
</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 flex-grow-1">
<li class="nav-item ">
<a class="nav-link mr-2" href="#">MEN</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">WOMEN</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">KIDS</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">HOME & LIVING</a>
</li>
<li class="nav-item">
<a class="nav-link mr-2" href="#">OFFERS</a>
</li>
</ul>
<div class="form-group has-search flex-grow-1">
<span class="fa fa-search form-control-feedback"></span>
<input type="text" class="form-control" placeholder="Search for Products Branda and More" />
</div>
</div>
</nav>
</div>
Explanation
The changes made are as follows:
in the tag with the class coco, I have renamed the class from
classname to class.
I have included the container-fluid which requires bootstrap 4 to make the menu wide. Otherwise there was no space to grow and it all came together. finally
I have applied flex, to give similar entities to the menu and to the search field. You can do this by adding the "flex-grow-1" class to each of the tags of both entities. If you want one to be greater than the other, you can remove that class from a tag and see what happens.
You can see this code running on pure css + html in the next link
Importante notice: I´m not familiar with react. So I changed from react code to pure thml + css code. But I´m assuming that you can understand as well.
Good luck!
I'm using Bootstrap for my navigation bar, and somehow I keep getting whitespace on the right side of the logo image. My navigation code looks like this:
.navbar {
background-color: white;
opacity: 80%;
font-size: 0.8em;
}
.nav-link a {
color: black;
}
.nav-item img {
width: 110px;
margin-top: 8px;
margin-left: 10px;
margin-right: 20px;
}
.nav-item a {
color: black;
}
.navButtons {
background-color: white;
color: black;
padding: 6px;
font-size: 12px;
}
.navButtons:hover {
color: black;
text-decoration: none;
}
<style>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</style>
<nav class="navbar fixed-top navbar-expand-sm navbar-light">
<a class="navbar-brand" href="index.html" style="margin:0;">
<img src="https://via.placeholder.com/468x60?text=Visit+Blogging.com+Now" alt="logo" style="width: 50%;">
</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="navbar-collapse collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="button navButtons" href="about.html"> Biography <span class="sr-only">(current)</span> </a>
</li>
<li class="nav-item">
<a class="button navButtons" href="interiorDesigns.html"> Interior Design </a>
</li>
<li class="nav-item">
<a class="button navButtons" href="arts.html"> Arts </a>
</li>
<li class="nav-item">
<a class="button navButtons" href="blogs.html"> Blogs </a>
</li>
<li class="nav-item">
<a class="button navButtons" href="contact.html"> Contact </a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<div class="form-group mb-4">
<input type="search" placeholder="Search" class="form-control form-control-underlined">
</div>
</form>
</div>
</nav>
And this is what my logo looks like, the yellow part is where I want to get rid of. I tried changing the padding, margin, and width, but none worked.:
In your Example the Anchor tag is is a block element/parent container of the image.
Apply width and padding-right(if required) to the navbar-brand.
Then instead of adding 50% width make it 100% to the img tag inside.
This will fix your issue.
Example Code (last two lines) in CSS then tag:
.navbar-brand {
display: inline-block;
padding-top: .3125rem;
padding-bottom: .3125rem;
margin-right: 1rem;
font-size: 1.25rem;
line-height: inherit;
white-space: nowrap;
width: 300px;
padding-right: 50px;
}
<img src="https://via.placeholder.com/468x60?text=Visit+Blogging.com+Now" alt="logo" style="width: 100%;">
I have been trying to make my navbar transparent but so far nothing has worked for me. Can someone teach me how to do it? I assume it has something to do with the space that it is taking up in regards to the body content, but I am not sure what can be done as I have already tried reversing the div tags to be outside of the body.
This is my desired result :
Fiddle : https://jsfiddle.net/zr1qh780/
My HTML :
<body>
<div id="container">
<!-- Navigation menu -->
<header>
<nav class="my-nav navbar navbar-light navbar-expand-lg">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarsExample08" aria-controls="navbarsExample08" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-md-center" id="navbarsExample08">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="index.html" id="dropdown08" data-toggle="dropdown" aria-
haspopup="true" aria-expanded="false">ACTIVITÉS</a>
<div class="dropdown-menu" aria-labelledby="dropdown08">
<a class="dropdown-item" href="rafting.html">Rafting</a>
<a class="dropdown-item" href="canyoning.html">Canyoning</a>
<a class="dropdown-item" href="saut-parachute.html">Saut en parachute</a>
<a class="dropdown-item" href="soufflerie.html">Simulation de chute libre</a>
<a class="dropdown-item" href="saut-elastique.html">Saut à l’élastique</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">OFFRES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ÉVÉNEMENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">À PROPOS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ESPACE HANDICAP</a>
</li>
<li class="nav-item">
<a class="nav-link contact" href="contact.html">CONTACT</a>
</li>
</ul>
</div>
<div class="hamburger">
<span style="font-size:30px;cursor:pointer;color: white;" onclick="openNav()">☰</span>
</div>
</nav>
</header>
<div id="myNav" class="overlay">
×
<div class="bar overlay-content">
ACTIVITÉS
OFFRES
ÉVÉNEMENTS
À PROPOS
ESPACE HANDICAP
CONTACT
</div>
</div>
My CSS:
.logo {
margin-right:5px;
}
.my-nav{
display: flex;
align-items: center;
justify-content: space-around;
padding: 8px;
}
.navbar-light .navbar-nav .nav-link {
color: white;
}
.navbar-nav > li {
padding-left:25px;
padding-right:45px;
float:none;
display:table-cell;
text-align:center;
font-size: 15px;
font-weight: 500;
}
.navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover {
color: #fc3218;
}
.nav-link:active {
color: #fc3218;
}
.navbar {
background: grey
}
.dropdown-menu {
color: white;
background-color: #fc3218;
}
.dropdown-item {
color: white;
font-size: 14px;
}
.navbar-collapse {
flex-grow: 0.3;
}
Have you tried something like this?
navbar{
background-color: transparent;
}
If that doesn't work, add !important to break the predefined bootstrap styles
Set the opacity of the container for nav bar to 0.
Note: Place the elements of nav bar in different div otherwise the text in nav bar will also get effected.
I'm kinda new to web-development using bootstrap and I'm trying to achieve something with my footer...
Actually my footer is looking like this for the desktop version of my website:
the footer elements are displayed in line without any issue...
But if I change the page's resolution until I reach the mobile design of it my footer elements are stacked on top of each others instead of still being inline:
I tried to fix that to use media queries and css, to add a display : inline-block to the html list but it didn't worked, and I don't really know what I should use to keept it displayed correctly.
Here is the code pen of the footer :
https://codepen.io/rgmislife/pen/poJJeyV
.footer-page {
background-color: #d2d7e8;
right: 0;
bottom: 0;
left: 0;
/**position:absolute;**/
position: relative;
width: 100%;
height: auto;
}
#media screen and (min-width: 320px) and (max-width: 1024px) {
.footer-page {
position: relative;
}
}
#media screen and (min-width: 768px) and (max-width: 1024px) {
.footer-page {
position: absolute;
}
}
.navbar-brand {
font-family: 'Raleway', regular;
color: white;
font-size: 15px;
letter-spacing: 1px;
}
.icon {
font-size: 0.4rem;
}
.nav-link {
font-family: 'Raleway', Semi-Bold;
letter-spacing: 1px;
color: #3a5199;
font-size: 15px;
letter-spacing: 1px;
no
}
<link href="//use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<footer>
<div class="footer-page">
<nav class="navbar navbar-fixed-bottom navbar-expand-md bg-faded justify-content-center">
Brand
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100" id="collapsingNavbar3">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#"><i class="fab fa-linkedin fa-2x"></i></a>
</li>
<li class="nav-item d-inline-block">
<a class="nav-link" href="nous-contacter.php"><i class="fas fa-envelope fa-2x"></i></a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto w-100 justify-content-end">
<li class="nav-item">
<a class="nav-link" href="nous-contacter.php">Nous contacter</a>
</li>
<li class="nav-item">
<a class="nav-link" href="mentions.html">Mentions Légales</a>
</li>
<li class="nav-item">
<a class="nav-link" href="CGV.html">CGV</a>
</li>
<li class="nav-item">
<a class="nav-link" href="presse.html">Presse</a>
</li>
<li class="nav-item">
<a class="nav-link" href="evenements.html">Evénements</a>
</li>
</ul>
</div>
</nav>
</div>
</footer>
and thats is the css code I tried :
.nav li {display: inline-block;}
If anyone has an idea feel free to let me know.
Thanks.
Is this what you're looking for?
#media screen and (max-width:768px){
.navbar-nav{
flex-direction: row;
}
.navbar-nav .nav-item{
margin: 0 10px;
}
}
Your elements are going to stack on mobile regardless based off text length and screen sizes
Your links are stacked, because they don't fit into container. You nothing can do without changing your html structure. And I suggest you to organize the layout ones more. Now it looks quite messy.
Quick fix, just to see what can be done (I see that you use bootstrap, so I base on that):
remove w-50 from navbar-brand link. It is the main reason of links stacking.
Now you want your icons are in the center, and as I understand you want keep them inside navbar-collapse together with links. So remove ml-auto w-100 from ul navbar-nav where are the links. Add mx-autoto ul where icons are, it makes them be in the center between brand and links.
Look into the snippet in full page mode.
.footer-page {
background-color: #d2d7e8;
right: 0;
bottom: 0;
left: 0;
/**position:absolute;*/
position: relative;
width: 100%;
height: auto;
}
#media screen and (min-width: 320px) and (max-width: 1024px) {
.footer-page {
position: relative;
}
}
#media screen and (min-width: 768px) and (max-width: 1024px) {
.footer-page {
position: absolute;
}
}
.navbar-brand {
font-family: 'Raleway', regular;
color: white;
font-size: 15px;
letter-spacing: 1px;
}
.icon {
font-size: 0.4rem;
}
.nav-link {
font-family: 'Raleway', Semi-Bold;
letter-spacing: 1px;
color: #3a5199;
font-size: 15px;
letter-spacing: 1px;
}
<link href="//use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<footer>
<div class="footer-page">
<nav class="navbar navbar-fixed-bottom navbar-expand-md bg-faded justify-content-center">
Brand
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse w-100" id="collapsingNavbar3">
<ul class="navbar-nav mx-auto">
<li class="nav-item active">
<a class="nav-link" href="#"><i class="fab fa-linkedin fa-2x"></i></a>
</li>
<li class="nav-item d-inline-block">
<a class="nav-link" href="nous-contacter.php"><i class="fas fa-envelope fa-2x"></i></a>
</li>
</ul>
<ul class="nav navbar-nav justify-content-end">
<li class="nav-item">
<a class="nav-link" href="nous-contacter.php">Nous contacter</a>
</li>
<li class="nav-item">
<a class="nav-link" href="mentions.html">Mentions Légales</a>
</li>
<li class="nav-item">
<a class="nav-link" href="CGV.html">CGV</a>
</li>
<li class="nav-item">
<a class="nav-link" href="presse.html">Presse</a>
</li>
<li class="nav-item">
<a class="nav-link" href="evenements.html">Evénements</a>
</li>
</ul>
</div>
</nav>
</div>
</footer>
I am trying to build a website with Angular6 where there is a vertical navbar when viewed on a large screen and a top navbar with a dropdown on mobile. With Bootstrap 4. I have found multiple examples online but they all seems overly complicated or build without the nav template.
The example project from ASP.Net Core with Angular have a navbar like I want but it is written with Bootstrap3. I have tried to convert it without success and this is where I ask for your help!
Original Code with Bootstrap 3. If you have dotnet core installed, you can use dotnet new angular -o my-new-app to create the project.
HTML
<div class='main-nav'>
<div class='navbar navbar-inverse'>
<div class='navbar-header'>
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse' [attr.aria-expanded]='isExpanded' (click)='toggle()'>
<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' [routerLink]='["/"]'>my_new_app</a>
</div>
<div class='clearfix'></div>
<div class='navbar-collapse collapse' [ngClass]='{ "in": isExpanded }'>
<ul class='nav navbar-nav'>
<li [routerLinkActive]='["link-active"]' [routerLinkActiveOptions]='{ exact: true }'>
<a [routerLink]='["/"]' (click)='collapse()'>
<span class='glyphicon glyphicon-home'></span> Home
</a>
</li>
<li [routerLinkActive]='["link-active"]'>
<a [routerLink]='["/counter"]' (click)='collapse()'>
<span class='glyphicon glyphicon-education'></span> Counter
</a>
</li>
<li [routerLinkActive]='["link-active"]'>
<a [routerLink]='["/fetch-data"]' (click)='collapse()'>
<span class='glyphicon glyphicon-th-list'></span> Fetch data
</a>
</li>
</ul>
</div>
</div>
CSS
li .glyphicon {
margin-right: 10px;
}
/* Highlighting rules for nav menu items */
li.link-active a,
li.link-active a:hover,
li.link-active a:focus {
background-color: #4189C7;
color: white;
}
/* Keep the nav menu independent of scrolling and on top of other items */
.main-nav {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1;
}
#media (min-width: 768px) {
/* On small screens, convert the nav menu to a vertical sidebar */
.main-nav {
height: 100%;
width: calc(25% - 20px);
}
.navbar {
border-radius: 0px;
border-width: 0px;
height: 100%;
}
.navbar-header {
float: none;
}
.navbar-collapse {
border-top: 1px solid #444;
padding: 0px;
}
.navbar ul {
float: none;
}
.navbar li {
float: none;
font-size: 15px;
margin: 6px;
}
.navbar li a {
padding: 10px 16px;
border-radius: 4px;
}
.navbar a {
/* If a menu item's text is too long, truncate it */
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
And here is my attempt to convert it. I used the Bootstrap 4 documentation for the template
<div class="main-nav">
<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="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse" id="navbarNavAltMarkup">
<div class="nav flex-column">
<a class="nav-item nav-link active" href="#">Home</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>
</div>
</nav>
</div>
The problem is that the title and the nav are on the same line instead of having then on separate line. How could I achieve that?
(The mobile view doesn't seem to work either, but I haven't tried yet. I am trying to make the desktop view work first)
Looks like I didn't search long enough. I found the solution here: http://www.codingflow.net/building-single-page-applications-on-asp-net-core-2-1-with-angular-6-part-2-upgrading-to-bootstrap-4/
One of the key changes was this in the css
.flex-column {
width: 100%;
}