Navbar fixed left - Bootstrap - html

I am trying to make navbar in bootstrap to be fixed left, like on this link.
Anyway, it is working, but when I add block content of the leaflet map, my navbar is still there, but I can't click on it. Also, I don't get pointer mouse when I cross over the link. Here is code which I changed:
<!--NAVBAR-->
<div class="navbar navbar-inverse navbar-fixed-left">
<a class="navbar-brand" href="#">Brand</a>
<ul class="nav navbar-nav">
<li class="dropdown">Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Sub Menu1</li>
<li>Sub Menu2</li>
<li>Sub Menu3</li>
<li class="divider"></li>
<li>Sub Menu4</li>
<li>Sub Menu5</li>
</ul>
</li>
<li>Link2</li>
<li>Link3</li>
<li>Link4</li>
<li>Link5</li>
</ul>
</div>
</div>
<div class="container col-sm-12">
<div class="row">
{% block map_content %}
replace me
{% endblock map_content %}
</div>
</div>
Before this, I tried more elegant solution. I used bootstrap4 and tried something like this:
<nav class="navbar navbar-inverse fixed-left">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="{% url 'index' %}"><p class="logo_name">page name</p></a>
</div>
<ul class="nav navbar-nav">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</nav>
But it doesn't work, in this case, my navbar is fixed top, and not left.

try adding these things. Add extra CSS to modify existing class.
Add this extra css:-
<style>
.navbar-fixed-left {
width: 140px;
position: fixed;
border-radius: 0;
height: 100%;
}
.navbar-fixed-left .navbar-nav > li {
float: none; /* Cancel default li float: left */
width: 139px;
}
.navbar-fixed-left + .container {
padding-left: 160px;
}
/* On using dropdown menu (To right shift popuped) */
.navbar-fixed-left .navbar-nav > li > .dropdown-menu {
margin-top: -50px;
margin-left: 140px;
}
</style>

Related

Equally split navbar with centered image

I am trying to achieve a navbar that is equally divided into 12 columns so that each li takes up one section each. I would like to have an image in my starting column. This is what I have so far:
html, body {
height: 100%; /*Fixes the height to 100% of the viewport*/
}
body {
padding-top: 65px; /*50px for the height of the navbar + 37px for the offset*/
}
.navbar-inverse {
background-color: #06658D;
border: 0;
}
.navbar-inverse .navbar-nav > li > a {
color: #FFF;
width: 100px;
line-height: 25px;
}
.navbar-inverse .navbar-nav > li > img {
max-height: 25px;
vertical-align: middle;
}
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css"/>
<link rel="stylesheet" href="css/layout.css"/>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container row">
<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="navbar-collapse collapse">
<ul class="nav navbar-nav ">
<li class="col-md-1"><img src="images/Home.png" alt="home"></li>
<li class="col-md-1">Column 2</li>
<li class="col-md-1">Column 3</li>
<li class="col-md-1">Column 4</li>
<li class="col-md-1">Column 5</li>
<li class="col-md-1">Column 6</li>
<li class="col-md-1">Column 7</li>
<li class="col-md-1">Column 8</li>
<li class="col-md-1">Column 9</li>
<li class="col-md-1">Column 10</li>
<li class="col-md-1">Column 11</li>
<li class="col-md-1">Column 12</li>
</ul>
</div>
</div>
</nav>
<div class="container body-content row">
#RenderBody()
</div>
#RenderSection("Scripts", required: false)
</body>
</html>
These two combined however result in this:
AS you can see I have two issues. Firstly the alignment of the image is all wrong as I would like that to be central both horizontally and vertically. Secondly my navbar is not divided up into 12 equal elements as they are not utilizing the full width of the navbar.
Try using display table property. I don't think you're gonna get equal li sizes but you'll get a result none the less.
ul {
display: table;
width: 100%;
}
ul li {
display: table-cell;
text-align: center;
}

Navbar element drops to second line instead of aligning to the right

Using Bootstrap to create a menu bar. My brand label is aligned far left. The main menu options are center aligned. I'm trying to get 'Logout' to be right aligned. But instead, its on a second line and centered.
<style>
body {
background-color: White;
margin-left: 40px;
margin-right: 40px;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
.navbar .navbar-right {
text-align: right;
display: inline-block;
float: none;
vertical-align: top;
}
</style>
<body id=<?php echo $bodyid ?>>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<a class="navbar-brand">Assessment Manager</a>
</div>
<div class="collapse navbar-collapse">
<div class="container">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Clients</li>
<li>Contacts</li>
<li>Employees</li>
<li>Findings</li>
<li>Projects</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Vulnerabilities<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Host</li>
<li>Web</li>
</ul>
</li>
</ul>
</div>
<div class="container">
<ul class="nav navbar-nav">
<li>
<span class="glyphicon glyphicon-log-out"></span> Logout
</li>
</ul>
</div>
</div>
See a picture of the menu bar here.
Put your <ul> elements in the same container. Also you have a CSS class navbar-right that wasn't used in your HTML. This HTML seems to work fine given a wide enough browser window:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<a class="navbar-brand">Assessment Manager</a>
</div>
<div class="collapse navbar-collapse">
<div class="container">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Clients</li>
<li>Contacts</li>
<li>Employees</li>
<li>Findings</li>
<li>Projects</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Vulnerabilities<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Host</li>
<li>Web</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<span class="glyphicon glyphicon-log-out"></span> Logout
</li>
</ul>
</div>
</div>
</div>
You could also experiment with float:right; on the <ul> for your login link (using the same navbar-right class.
Also, keep in mind that bootstrap intends for the container class to have row and col classes inside it to further wrap the content. By using only container you're missing out on a lot of the responsive behavior bootstrap is intended to provide.

foundation 6: how to center horizontal navigation with image

I use zurb foundation 6 and i'm pretty happy with it.
But i'm struggling with the header. My goal is to implement a main navigation like this:
How can i center the menu items inside a horizontal navigation with an image (logo) as a divider?
my attempt is to use an ul list for the nav items:
<nav class="row header show-for-large">
<div class="large-5 column">
<ul class="main-nav-left">
<li>Women</li>
<li>Men</li>
<li>Store</li>
<li>Blog</li>
</ul>
</div>
<div class="large-2 column ">
<%= image_tag("test-Logo.png", alt: "Nile Logo") %>
</div>
<div class="large-5 column">
<ul class="main-nav-right">
<li>EN & FR</li>
<li>Login</li>
<li>Wunschliste</li>
<li>Warenkorb</li>
</ul>
</div>
</nav>
I recently migrated the Centered Top Bar With Logo building block for Foundation 6. It should be exactly what you are after.
HTML
<!-- Small Navigation -->
<div class="title-bar" data-responsive-toggle="nav-menu" data-hide-for="medium">
<a class="logo-small show-for-small-only" href="#"><img src="http://placehold.it/50x50?text=LOGO" /></a>
<button class="menu-icon" type="button" data-toggle></button>
<div class="title-bar-title">Menu</div>
</div>
<!-- Medium-Up Navigation -->
<nav class="top-bar" id="nav-menu">
<div class="logo-wrapper hide-for-small-only">
<div class="logo">
<img src="http://placehold.it/350x150?text=LOGO">
</div>
</div>
<!-- Left Nav Section -->
<div class="top-bar-left">
<ul class="vertical medium-horizontal menu">
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
</ul>
</div>
<!-- Right Nav Section -->
<div class="top-bar-right">
<ul class="vertical medium-horizontal dropdown menu" data-dropdown-menu>
<li class="has-submenu">
Menu 4
<ul class="submenu menu vertical medium-horizontal" data-submenu>
<li>First link in dropdown</li>
</ul>
</li>
<li class="has-submenu">
Menu 5
<ul class="submenu menu vertical" data-submenu>
<li>First link in dropdown</li>
</ul>
</li>
</ul>
</div>
</nav>
SCSS
/* Variables */
// Adjust width accordingly (use even #'s)
$logo-width: 118px;
// Reduce px value to increase space between logo and menu text
$logo-padding: $logo-width - 32px;
// Leave alone
$logo-margin: - ($logo-width / 2);
/* Small Navigation */
.logo-small {
float: right;
}
.title-bar {
padding: 0 .5rem;
}
.menu-icon,
.title-bar-title {
position: relative;
top: 10px;
}
/* Medium-Up Navigation */
#media only screen and (min-width: 40rem) {
.logo-wrapper {
position: relative;
.logo {
width: $logo-width;
height: 92px;
position: absolute;
left: 50%;
right: 50%;
top: -6px;
margin-left: $logo-margin;
}
}
// Right part
.top-bar-right {
width: 50%;
padding-left: $logo-padding;
ul {
float: left;
}
}
// Left part
.top-bar-left {
width: 50%;
padding-right: $logo-padding;
ul {
float: right;
}
}
}

Insert image at right of dropdown on Boostrap

I'm using Bootstrap to create a navbar in the top of the page, but i'm facing some problems:
After opening the navbar dropdown, I need to have a option list, and a image positioned to the right of the list. This image needs to have the same height of the list, just like in the following image (in portuguese, but easily understandable).
I achieved this setting a fixed height and width on the image, but the list can grow up and isn't a good option adjust it manually.
Another solution is to insert a div containing the list and the image, and set the image size to 100%, but when I do this, the dropdown isn't achieved anymore (I think i'm breaking the structure that Bootstrap uses to toggle the dropdown, am I right?).
How can I achieve this solution?
<div id="navbar" class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav top-elements">
<li id="dropdown-produtos" class="dropdown">
Nossos Produtos<span class="caret top-caret"></span>
<!-- div was here --> <ul class="dropdown-menu dropdown-menu-produtos">
<li class="dropdown-item-active">
texto1
<ul class="dropdown-menu img-dropdown">
<img src="assets/img.png">
</ul>
</li>
<li class="dropdown-item">
texto2
</li>
<li class="dropdown-item">texto3</li>
<li class="dropdown-item">texto4</li>
<li class="dropdown-item">texto5</li>
</ul>
</li>
</ul>
</div>
This should work:
<ul class="nav navbar-nav">
<li>Elemento 1</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">DropDown<span class="caret"></span></a>
<ul class="dropdown-menu another-class">
<!-- ROW -->
<div class="col-md-12">
<!-- Column 1 -->
<div class="col-md-6">
<ul class="list-unstyled">
<li>Texto 1</li>
<li>Texto 2</li>
<li>Texto 3</li>
</ul>
</div>
<!-- Column 2 -->
<div class="col-md-6">
<div class="drop-image">
<img src="./img/img.jpg" class="img-responsive" />
</div>
</div>
</div>
</ul>
</li>
<li>Elemento 2</li>
<li>Elemento 3</li>
</ul>
Basically what I'm doing is create a div with a full width inside the dropdown element that comes as default in Boostrap. Inside this Full width row I create two columns with bootstrap col-md-6 class (you can do this with col-lg or col-sm or col-xs too) Inside this columns I add my content normally.
I created a class in the column 2 named "drop-image"; use this class to modify the img inside.
Hope it helps!
Btw, don't forget to style your dropdown (in the example I mark it with a class named another-class) so you define the position and width.
This might solve your problem, it's based off this plugin Yamm3!. See example Snippet.
Change this CSS rule if you need to make the dropdown wider because of the length of the link text. >
.list-unstyled, .list-unstyled ul {
min-width: 180px
}
body {
padding-top: 60px;
color: #666;
}
/* menu styes */
.list-unstyled,
.list-unstyled ul {
min-width: 180px
}
.list-unstyled > li {
padding-top: 10px;
}
.list-unstyled > li > a {
color: #555;
text-decoration: none;
}
.yamm .nav,
.yamm .collapse,
.yamm .dropup,
.yamm .dropdown {
position: static;
}
.yamm .container {
position: relative;
}
.yamm .dropdown-menu {
left: auto;
background: #f5f5f5;
}
.yamm .yamm-content {
padding: 0 30px 10px 30px;
}
.yamm .yamm-content .nav-title {
margin-left: 15px;
}
.yamm .dropdown.yamm-fw .dropdown-menu {
left: 0;
right: 0;
}
#media (max-width: 767px) {
.yamm-content .list-unstyled > li img {
margin-top: -180px;
float: right;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar yamm navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" data-toggle="collapse" data-target="#navbar-collapse-1" class="navbar-toggle"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>Grande Menu
</div>
<div id="navbar-collapse-1" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<!-- Classic list -->
<li class="dropdown">Nossos Produtos<b class="caret"></b>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<div class="row">
<h4 class="nav-title"><strong>A partida de um</strong></h4>
<ul class="col-sm-4 list-unstyled">
<li>Vinculando um
</li>
<li>Ligando dois
</li>
<li>Ligação de três
</li>
<li>Quatro ligação
</li>
<li>Ligação cinco
</li>
<li>Seis ligação
</li>
</ul>
<ul class="col-sm-2 list-unstyled">
<li>
<img src="http://placehold.it/150x150/ff0/fff">
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<!-- Classic list -->
<li class="dropdown">Nossos Produtos Dois<b class="caret"></b>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<div class="row">
<h4 class="nav-title"><strong>A partida de um</strong></h4>
<ul class="col-sm-4 list-unstyled">
<li>Vinculando um
</li>
<li>Ligando dois
</li>
<li>Ligação de três
</li>
<li>Quatro ligação
</li>
<li>Ligação cinco
</li>
<li>Seis ligação
</li>
</ul>
<ul class="col-sm-2 list-unstyled">
<li>
<img src="http://placehold.it/150x150/ff0/fff">
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="alert alert-warning">Olá</div>
</div>

How to put height 100% at the links of a navbar?

I'm using twitter-bootstrap, and I have the following code to generate an navbar with an avatar in a dropdown:
Check this fiddle: http://jsfiddle.net/X4drb/embedded/result/
HTML
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <i class="fa fa-bars"></i>
</button> <a class="navbar-brand" href="index.html"><img src="http://placehold.it/30x30&text=logo" ></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Hello
</li>
<li>Stack
</li>
<li>Overflow
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"> <img id="avatar" class="img-circle mr1" src="http://placehold.it/30x30&text=photo" > John Doe <b class="caret"></b>
<ul class="dropdown-menu">
<li>Settings
</li>
<li>Logout
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
CSS
.caret {
margin-left: 5px;
}
#avatar, .navbar-brand {
margin-right: 5px
}
.navbar-nav {
height: 100%;
margin: 0;
padding 0;
}
But, as you see, the list of the links with Hello, Stack and Overflow doesn't reach the end of the navbar:
Do you have any idea to fix it? I tried putting height: 100%; padding: 0; margin: 0 to the list items of the links, but nothing changes.
Try line-height?
ul.nav.navbar-nav li a:link {
line-height: 32px;
}
http://jsfiddle.net/X4drb/9/
Your ul is not getting proper height. Give the height of ul same as outer div.