I am using Bootstrap to show a nav-bar:
As you may see in the screenshot, the first menu element appears at the bottom, not at the same height as the others menu elements.
Here is the CSS and HTMl code:
CSS
<style>
body {
font-family: 'Roboto', serif;
font-size: 16px;
}
#portada {
background-color: #F1F7F8;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
color: #4496B0; /*Sets the text hover color on navbar*/
}
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active >
a:hover, .navbar-default .navbar-nav > .active > a:focus {
color: white; /*BACKGROUND color for active*/
background-color: #4496B0;
}
.navbar-default {
background-color: #94C3D2;
border-color: #4496B0;
}
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
color: #262626;
text-decoration: none;
background-color: #66CCFF; /*change color of links in drop down here*/
}
.nav > li > a:hover,
.nav > li > a:focus {
text-decoration: none;
background-color: silver; /*Change rollover cell color here*/
}
.navbar-default .navbar-nav > li > a {
color: white; /*Change active text color here*/
}
.navbar-brand {
padding: 0px;
}
.navbar-brand>img {
height: 68px;
padding: 7px 15px;
width: 180px;
}
</style>
HTML
<div class="bs-example">
<nav role="navigation" class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header navbar-brand">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-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" href="index.html"><img src="imagenes/logo_pleca.png" alt="Vico">
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li >Inicio</li>
<li class="active">Doctores</li>
<li>Hospitales</li>
<li>Farmacias</li>
<li>Laboratorios</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Contactar</li>
<li>Login</li>
</ul>
</div>
</nav>
</div>
I am not able to find a solution for this issue.
Close </a> image
<div class="bs-example">
<nav role="navigation" class="navbar navbar-default">
<div class="navbar-header navbar-brand">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-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" href="index.html"><img src="imagenes/logo_pleca.png" alt="Vico"></a>
</div>
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>Inicio</li>
<li class="active">Doctores</li>
<li>Hospitales</li>
<li>Farmacias</li>
<li>Laboratorios</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Contactar</li>
<li>Login</li>
</ul>
</div>
</nav>
</div>
Check this fiddle Fiddle
Few tag missing check HTML code:
<div class="bs-example">
<nav role="navigation" class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header navbar-brand">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-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" href="index.html"><img src="imagenes/logo_pleca.png" alt="Vico"></a>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Inicio</li>
<li>Doctores</li>
<li>Hospitales</li>
<li>Farmacias</li>
<li>Laboratorios</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Contactar</li>
<li>Login</li>
</ul>
</div>
</div>
</nav>
</div>
Problem is <a class="navbar-brand" href="index.html"><img src="imagenes/logo_pleca.png" alt="Vico"> there is no closing anchor tag which is the reason for improper layout.
It should be
<a class="navbar-brand" href="index.html">
<img src="imagenes/logo_pleca.png" alt="Vico">
</a>
</div>
Demo : https://jsfiddle.net/yn2xeq6z/
Related
I'm having a lot of trouble adding a fixed black background to my bootstrapped navbar. In my CSS, I declared the background-color as black, but it doesn't seem to change anything. My own CSS is declared after bootstrap's core CSS, so it wouldn't be overridden by a default color. The nav bar shows as transparent, with opaque lettering. Not sure what the problem is, especially since I already declared the color of the navbar!
Here is the HTML for the navbar:
<div class="jumbotron">
<div class="container">
<nav class="navbar fixed-top">
<div class="navbar-fixed-top container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>About</li>
<li>
Personal Projects<span class="caret"></span>
</li>
<li>Bullet Blog</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav
And here is my CSS. Please help. I am going insane.
.jumbotron navbar-fixed-top container{
background: #2E2F31;
position: fixed;
width: 100%;
}
.navbar .navbar-nav li a {
color: white;
font-size: 16px;
}
.navbar .navbar-nav li a:hover {
background: #BFC1C3;
}
.navbar .navbar-nav .dropdown-menu li a:hover {
background: #BFC1C3;
}
change your css from .jumbotron navbar-fixed-top container to .jumbotron .navbar-fixed-top.container I updated your code check here
.jumbotron .navbar-fixed-top.container{
background: #2E2F31;
position: fixed;
width: 100%;
}
.navbar .navbar-nav li a {
color: white;
font-size: 16px;
}
.navbar .navbar-nav li a:hover {
background: #BFC1C3;
}
.navbar .navbar-nav .dropdown-menu li a:hover {
background: #BFC1C3;
}
<html lang="en">
<head>
<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.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="navbar-inverse jumbotron">
<div class="container">
<!-- Header -->
<nav class="navbar fixed-top">
<div class="navbar-fixed-top container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>About</li>
<li>
Personal Projects<span class="caret"></span>
</li>
<li>Bullet Blog</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
</body>
</html>
I think this is exactly what you need
<head>
<link rel="stylesheet" href="farji.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class=" jumbotron">
<div class="container">
<!-- Header -->
<nav class="navbar-fixed-top navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home <span class="sr-only">(current)</span></li>>
<li>About</li>
<li>
Personal Projects<span class="caret"></span>
</li>
<li>Bullet Blog</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
</body>
OPTIONAL--and if you want to change it even further with any other color use the following css:
.navbar-inverse {
background-color: #122c46;
border-color: #122c46;
}
The toggle button appears in mobile view but it's not clickable. In angular appDropdown is used to define a drop down button. Is there a similar approach to fix the toggle button?
Unfortunately I cannot show images here but there's another problem with "Administration" drop down button. It changes colour to grey when I hover over the internal <li> (such as "Registration"...).
Adding href= "#" removes the unwanted color change but this refreshes the whole page when its clicked.
Here's the HTML:
<nav class="navbar navbar-webmaster">
<div class="container">
<div class="navbar-header">
<button type="button" appDropdown class="navbar-toggle collapsed" data-toggle="collapse" data-target="#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" [routerLink]="['/']">Title</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<ul class="nav navbar-nav navbar-right">
<li class="active">Sublime<span class="sr-only"></span></li>
<li class="dropdown" appDropdown *ngIf="userService.isAdmin">
<a class="dropdown-toggle" role="button" aria-haspopup="true" aria-expanded="false">Administration <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a [routerLink]="['/register']">Registration</a></li>
<li><a>Other Admin Stuff</a></li>
<li role="separator" class="divider"></li>
<li><a>Another Admin Stuff</a></li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-right search-form" role="search">
<input type="text" class="form-control" placeholder="Search" />
</form>
</div>
</div>
The CSS:
nav.navbar-webmaster {
background: #00547E;
}
nav.navbar-webmaster a {
color: #fff;
}
nav.navbar-brand :hover {
color: #337ab7;
}
nav.navbar-webmaster ul.navbar-nav a:hover,
nav.navbar-webmaster ul.navbar-nav a:visited,
nav.navbar-webmaster ul.navbar-nav a:focus,
nav.navbar-webmaster ul.navbar-nav a:active {
background: #0d3a51;
}
nav.navbar-webmaster ul.navbar-nav a:hover {
border-color: #337ab7;
}
nav.navbar-webmaster li.divider {
background: #ccc;
}
nav.navbar-webmaster button.navbar-toggle {
background: #999;
border-radius: 2px;
}
nav.navbar-webmaster button.navbar-toggle:hover {
background: #999;
}
nav.navbar-webmaster button.navbar-toggle>span.icon-bar {
background: #fff;
}
nav.navbar-webmaster ul.dropdown-menu {
border: 0;
background: #fff;
}
nav.navbar-webmaster ul.dropdown-menu>li>a {
color: #444;
}
nav.navbar-webmaster ul.dropdown-menu>li>a:hover {
background: #00547E;
color: #fff;
}
Any help is greatly appreciated.
Implemented by using ng-bootstrap. Update html as below
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" (click)="isCollapsed = !isCollapsed" [attr.aria-expanded]="!isCollapsed" aria-controls="myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar" [ngbCollapse]="isCollapsed">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Projects</li>
<li>Contact</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-log-in"></span> Login</li>
</ul>
</div>
</div>
</nav>
Declare below variable in component class
public isCollapsed = false;
For live action, visit my Plunker
I'm trying to get this:
But don't get it (lol) and having this instead:
Don't know where to adjust the thing.
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
#menu {
height: 140px;
}
<header>
<nav class="navbar navbar-default" id="menu">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 col-sm-3">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="index.html">
<img alt="Brand" src="img/logo.png" height="100px;">
</a>
</div>
</div>
<div class="col-md-9 col-sm-9">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav ">
<li class="active">Accueil <span class="sr-only">(current)</span></li>
<li>Page 1</li>
<li>Page 2</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
</header>
Do you have any idea ? When i tried to fix it with the height it increased the navbar height...
Try to add this code:
.navbar-default .navbar-nav > li > a {
line-height: 140px; /* = height of #menu */
padding-bottom: 0;
padding-top: 0;
}
Check the result:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: black;
box-shadow: inset 0px -6px 0px #000;
}
#menu {
height: 140px;
}
.navbar-default .navbar-nav > li > a {
line-height: 140px; /* = height of #menu */
padding-bottom: 0;
padding-top: 0;
}
<header>
<nav class="navbar navbar-default" id="menu">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 col-sm-3">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="index.html">
<img alt="Brand" src="img/logo.png" height="100px;">
</a>
</div>
</div>
<div class="col-md-9 col-sm-9">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav ">
<li class="active">Accueil <span class="sr-only">(current)</span></li>
<li>Page 1</li>
<li>Page 2</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
</header>
I am trying to do a custom button style in my navbar in bootstrap but it's taking on the default styles of the navbar. What I am trying to do is make two buttons in the navbar that say sign up and login. I want them to be in-line with the rest of the menu items but to be "buttons" that have a border with no background. Yet they appear with the btn-primary coloring.
This is the code I am using:
.btn.outline {
background: none !important;
padding: 12px 12px;
}
.btn-primary.outline {
border: 2px solid #0099cc;
color: #0099cc;
}
.btn-primary.outline:hover, .btn-primary.outline:focus, .btn-primary.outline:active, .btn-primary.outline.active, .open > .dropdown-toggle.btn-primary {
color: #33a6cc;
border-color: #33a6cc;
}
.btn-primary.outline:active, .btn-primary.outline.active {
border-color: #007299;
color: #007299;
box-shadow: none;
}
I call to it like this:
<li>
<p class="navbar-btn">
Sign Up
</p>
</li>
Can anyone spot what I am doing or missing causing it to ignore my CSS?
Thanks!
Edit: I used the !important in hopes it would override the bootstrap.css
Edit again: here's my navbar code:
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#home"><img src="Landing/img/logo3.png" class="img-responsive2"></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav pull-right mainnav">
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
<li>
<p class="navbar-btn">
Sign Up
</p>
</li>
<li>
<p class="navbar-btn">
Login
</p>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
Looks like it's working to me using BS 3.3.4.
I grabbed the default navbar code from the BS website and placed yours into it. Check this fiddle - it's a button with no background and a blue border.
Perhaps you have some things in the wrong place?
<style>
.btn.outline {
background: none !important;
padding: 12px 12px;
}
.btn-primary.outline {
border: 2px solid #0099cc;
color: #0099cc;
}
.btn-primary.outline:hover, .btn-primary.outline:focus, .btn-primary.outline:active, .btn-primary.outline.active, .open > .dropdown-toggle.btn-primary {
color: #33a6cc;
border-color: #33a6cc;
}
.btn-primary.outline:active, .btn-primary.outline.active {
border-color: #007299;
color: #007299;
box-shadow: none;
}
</style>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="#">Brand</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<p class="navbar-btn">
Sign Up
</p>
</li>
</ul>
</div>
</div>
</nav>
I have a weird margin below bootstrap navbar and I don't know how to remove it. Any solutions with manipulate with margin or padding doesn't working.
HTML
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#"><span class="glyphicon glyphicon-home"></span></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Active example <span class="sr-only">(current)</span></li>
<li>Example 3</li>
<li>Example 2 </li>
</ul>
</div>
</div>
</nav>
<!-- HEADER -->
<div class="container-fluid" style="margin-top: -20px; margin-bottom: 25px;">
<div class="row">
<img src="http://thehrblog.ecornell.com/wp-content/uploads/sites/2/2013/04/communication.png" class="img-responsive">
</div>
</div>
CSS
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
background-color: #007DBE;
color: #FFF;
}
Example is here: Jsfiddle (please resize 'Result' if menu in navbar is hidden).
I need to remove this space:
for get this:
The file navbar.less is adding a border on the navbar:
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
So you can use this to reset:
.navbar-fixed-top {
border:0;
}
UpdatedFiddle
Change
.navbar-fixed-top {
border-width: 0 0 1px;
top: 0;
}
to
.navbar-fixed-top {
border-width: 0;
top: 0;
}