I have problems with implementing a bootstrap header in my code, but I think it's not my fault, but I dont know how to fix it.
The nav menu is always in phone view or something. I put my code in a JSFiddle so you guys can see my problem :
Here's the link: https://jsfiddle.net/wx86vq2y/2/
and I got a screenshot like how it had to be: https://gyazo.com/aca2e255638350dc386812ea9878ecfe . Does somewhone know what is wrong? I cant solve this problem at this moment.
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Dize Design AOS-Header v.2</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<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="#">Project</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
you can solve it by replacing the beta version bootstrap 4 css to bootstrap 3 css bootstrap3 url
Please check the sample
Related
I built a header using bootstrap. But, when I use a inner stylesheet on that page for other elements the dropdown has a glitch. Doing Upper lower bootstrap CDN or jQuery CDN link doesn't fix my problem. Header only works whenever there is not inner stylesheet or external stylesheet link. How can I solve this problem?
This is the problem I am facing right now
via GIPHY
Please try this code, TO Bootstrap dropdown giving glitch with inner CSS style
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation" style="">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<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="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
I hope this code will be useful to you.
Thank you.
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?
This question already has answers here:
Bootstrap align navbar items to the right
(24 answers)
Closed 5 years ago.
I'm a newbie and would like to ask how do you position navbar items to the right in Bootstrap 4? I tried the solutions here Bootstrap 4 - Right Align Navbar Items but did not work.
I trying to understand the sample code from Bootstrap 4 and don't what is making the search form align to the right?
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<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 my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
mr-auto does not align nav items to the right using the below,
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggler40" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggler40">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mt-2 mt-lg-0 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>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Dropdown link </a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
</div>
</nav>
It is the .mr-auto class set on the navbar menu (the <ul> tag) that pushes the form to the right.
The #navbarTogglerDemo01 tag has 3 immediate children: the <a>, <ul> and <form> tags. Normally they all would be left aligned, but the class mentioned above set the right margin of the <ul> tag to auto.
This is the actual css stlye:
.mr-auto {
margin-right: auto !important;
}
You can read more on this under the Spacing utilities section of the Bootstrap 4 docs.
Update in response of the comment:
Consider the example below. Apart from the color scheme, the only difference between the two navbars is the usage of the .mr-auto class. The upper one uses it, and has the form pushed to the right end, while the lower navbar does not use it, thus the form stands next to the menu items.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<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 my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" 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 navbar-expand-lg navbar-dark bg-primary">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mt-2 mt-lg-0">
<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 my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
So in case you would like to align the entire menu to the right, than you have two easy options. The example below uses the .mr-auto class on the branded <a> tag. Your another option could be to change the .mr-auto class to .ml-auto on the <ul> element.
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<a class="navbar-brand mr-auto" href="#">Hidden brand</a>
<ul class="navbar-nav mt-2 mt-lg-0">
<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 my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
I am trying to remove the padding between menu and navbar margin. I cant seem to find an answer.
header nav #logo {
padding: -10px; }
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="background-color: red;">
<a class="navbar-brand" href="#">
<img id="logo" src="images/logo.png" width="60" height="60">
</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>
<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 my-2 my-lg-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>
</header>
Use the Bootstrap 4 spacing utilites for padding.
Decrease Padding Navbar Example
py-0 sets vertical (y-axis) padding to 0.
<nav class="navbar navbar-dark py-0 bg-primary navbar-expand-lg">
<a class="navbar-brand" href="#">Logo</a>
<div class="navbar-collapse collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item py-0">Link</li>
</ul>
</div>
</nav>
In my case it was not the nav that had the pading, it was the body. To the body I put py-0 in his class and ready
my issue here is that i have a component that has functions that i want my app.component.html to have access to
book.component.html
<div class="form-inline">
<input id="inputSearchBar" class="form-control mr-sm-2" type="text" placeholder="Search" [(ngModel)]="Text">
<button class="btn btn-outline-info my-2 my-sm-0" type="submit" (click)="onSearch()">Search</button>
</div>
Now this is currently working because i have this line of code on my book.component.html, what i want is to use this on my app.component.html inside the navbar
app.component.html
<header>
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse">
<button class="navbar-toggler navbar-toggler-right" type="button"
data-toggle="collapse"
aria-controls="navbarColor01"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarColor01" >
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#" [routerLink]="['']">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['about']">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['books']">Books</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" >Register</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" [routerLink]="['login']">Login</a>
</li>
</ul>
</div>
</nav>
</header>
I want to have that searchbox as part of my navbar and it being functional, what should i add on my components or what should i do to make it work.
you can use parent and child relation ship here. create component for search bar and add in the Parent component.
1)
create search component like this
#Component({
selector: 'search-component',
})
export class searchcomponent { }
2) Add in the parent HTML
app.component.html
<header>
<search-component> </search-component>
</header>
More info check this link https://angular.io/docs/ts/latest/cookbook/component-communication.html
You can use service for this task:
https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service