I have a navbar brand image of 408px x 130. The navigation look correct in browser but i cannot make it responsive on mobile. Also the menu button does not appear. This is my navbar
<nav class="navbar default-nav">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="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" href="/"> <img alt="#{site_title}" src="/images/logo_white.png" /></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav nav-pills navbar-right">
<li>1</li>
<li>2</li>
<li>3
</li>
<li></li>
<li class="dropdown">Accedi
<ul id="login-dp" class="dropdown-menu">
<li>
<div class="row">
<div class="col-md-12">
<form action="/" method="post" class="form">
<div class="form-group">
<label class="sr-only" for="form-username">Username</label>
<input type="text" id="username" name="email" placeholder="Email..." class="form-username form-control" />
</div>
<div class="form-group">
<label class="sr-only" for="form-password">Password</label>
<input type="password" name="password" placeholder="Password..." class="form-password form-control" id="password" />
<div class="help-block text-right">
<a href="/resetPassword"> <span class="login-link">Password dimenticata?</span>
</a>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Login</button>
</div>
<div class="checkbox">
<label> <input type="checkbox" id="rememberme" name="remember-me" /> <span>Ricordami</span>
</label>
</div>
</form>
</div>
<div class="bottom text-center">
<span>Non sei iscritto?</span> <a class="login-link" href="/register"><strong>Registrati</strong></a>
</div>
</div>
</li>
</ul></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
The style is pure bootstrap css out of this
navbar {
min-height: 130px;
line-height: 130px;
z-index: 1;
height: 130px;
}
which i need to fit the nav to the brand image height.
The problem is that when i use a mobile phone, the brand image does is not responsive, so the menu button does not appear and the logo gets all the screen...
JSFiddle
Technically the nav button is still there but because the nav element doesn't have the .navbar-default class, it isn't inheriting Bootstrap's styles. You can fix this by adding the following:
CSS
.navbar-toggle {
border-color: #ddd;
top: 37px;
}
.navbar-toggle .icon-bar {
background-color: #888;
}
You'll also need to add jQuery and Bootstrap js to enable the nav toggle for the menu
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
To fix the image you'll need to do the following (styles may need adjusting based on how you need it to look)
You can set the height of .navbar-brand to auto and remove the height from .navbar. Also, changing its box-sizing to content will allow the image to sit within the padding of the element. You'll then need to add the .img-responsive class to the logo image element.
CSS
.navbar-brand {
box-sizing: content-box;
height: auto;
}
#media (max-width: 767px) {
.navbar-brand {
max-width: 15em;
}
}
/* Optional to replace line-height centering */
#media (min-width: 768px) {
.nav {
position: relative;
top: 60px; /* ( .navbar height / 2 ) - ( #navbar height / 2 ) */
}
}
HTML
<!-- Add img-responsive class to your logo -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="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" href="/">
<img alt="#{site_title}" src="http://2.228.86.3:8080/images/quipark_logo_white.png" class="img-responsive" />
</a>
</div>
Here's a Codepen example: https://codepen.io/raptorkraine/pen/YrKMgg
Related
I know this has been asked a million times and I thought I had done it right, but when my friend checked my site out on his screen there was a gap between the footer and the bottom of his screen, because on my screen it sits perfectly.
The php code is from laravel, but I think this is a css issue.
I can't see where I went wrong with this.
My css
html, body{
height: 100%;
width: 100%;
}
.container-fluid {
padding-right: 0;
padding-left: 0;
padding-bottom: 20px;
}
.contact_wrapper {
background: #fff none repeat scroll 0 0;
height: 234px;
position: absolute;
}
My template
<body>
<div class="container-fluid">
<!-- BEGIN MENU SECTION -->
<nav class="navbar navbar-default main_menu_wrapper">
<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" 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 href="{!! url('/') !!}" class="navbar-brand">
<img src="{!! asset("img/logo-for-site2.jpg") !!}">
</a>
</div>
<div class="collapse navbar-collapse menu_wrapper" id="bs-example-navbar-collapse-1">
<form action="{!! route('search') !!}" method="POST" role="search" class="navbar-form navbar-right search">
{{ csrf_field() }}
<div class="form-group">
<input type="text" class="form-control" name="search" placeholder="Search...">
</div>
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span>
</button>
</form>
<ul class="nav navbar-nav navbar-right">
#foreach($menus_child as $grandfather)
#if($grandfather->menu_id)
<li>
#elseif($grandfather->title == 'Home')
<li class="parent {!! menu_active($grandfather->id) !!}">
#elseif(count($grandfather->menusP()->where('menu_id', '>', 0)->get()))
<li class="dropdown {!! menu_active($grandfather->id) !!}">
#else
<li class="parent {!! menu_active($grandfather->id) !!}">
#endif
#if(count($grandfather->menusP()->where('menu_id', '>', 0)->get()))
<a href="{!! url(getSeoLink($grandfather->id)) !!}" class="dropdown-toggle hidden-xs hidden-sm hidden-md desktop_dropdown" role="button" aria-haspopup="true" aria-expanded="false">
{!! $grandfather->title !!} <span class="caret"></span>
</a>
<a href="javascript:void(0);" class="dropdown-toggle visible-xs visible-sm visible-md mobile_dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
{!! $grandfather->title !!} <span class="caret"></span>
</a>
#else
{!! Html::link(getSeoLink($grandfather->id), $grandfather->title) !!}
#endif
#if(count($grandfather->menusP))
<ul class="dropdown-menu desktop">
#foreach($grandfather->menusP as $father)
#if($father->menu_id)
<li class="parent_child">
#else
<li>
#endif
{!! Html::link(getSeoLink($father->id), $father->title) !!}
#endforeach
</ul>
#endif
#endforeach
</ul>
</div>
</div>
</nav>
<!-- END MENU SECTION -->
<!-- BEGIN CONTENT SECTION -->
#yield('content')
<!-- END CONTENT SECTION -->
<!-- BEGIN FOOTER SECTION -->
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 contact_wrapper">
#include('contact::contact')
</div>
</div>
<!-- END FOOTER SECTION -->
</div>
I think I solved it. What I did was I put a div around #yield('content') and I added some extra css
html, body{
height: 100%;
width: 100%;
margin: 0; /* Add css */
padding: 0; /* Add css */
}
.container-fluid {
padding-right: 0;
padding-left: 0;
padding-bottom: 20px;
min-height: 100%; /* Add css */
position: relative; /* Add css */
}
.body-content{ /* Add css */
padding-bottom: 234px; /* Add css */
}
.contact_wrapper {
background: #fff none repeat scroll 0 0;
height: 234px;
position: absolute;
bottom: 0; /* Add css */
}
This question already has answers here:
Bootstrap 3 - disable navbar collapse
(6 answers)
Closed 5 years ago.
My Bootstrap nav has only two elements. How do I disable the collapsing feature for Bootstrap when you minimize the page? The Login button can easily fit even when I minimize the page.
/* Navigation */
.navbar-brand img {
width:30%;
height:100%;
}
.navbar-default {
padding-top:10px;
padding-bottom:10px;
}
.navbar {
background: #23272D !important;
}
#logo {
width: 83.33px;
height: 27.68px;
}
#login_button {
position: relative !important;
top: 7px !important;
}
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<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>
<div class="navbar-brand">
<a href='#'> <img src='http://logos-download.com/wp-content/uploads/2016/06/Udemy_logo.png' class='img-responsive' id='logo'> </a>
</div>
</div>
<div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
<button type="button" class="btn btn-danger" id='login_button'>Login</button>
</div>
</nav>
<!-- End of Navigation -->
Update Navigation part with below code
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-brand">
<img src="http://logos-download.com/wp-content/uploads/2016/06/Udemy_logo.png" class="img-responsive" id="logo">
</div>
<div class="pull-right">
<button type="button" class="btn btn-danger" id="login_button">Login</button>
</div>
</div>
</nav>
try this.
Normally, I would just do position: relative and do left: 500px. But, the best part about Bootstrap is that it's responsive. I don't want to get rid of the responsive feature of Bootstrap. How do I center an li in Bootstrap inside of my nav?
Please view the snippet in Full Page mode. My goal is to move the two "Links" to the middle of the div. They are both li's. How do I accomplish this?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- This file has been downloaded from Bootsnipp.com. Enjoy! -->
<title>Fancy navbar login / sign in form - Bootsnipp.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body{
background:url('http://www.wallpaperup.com/uploads/wallpapers/2012/10/21/20181/cad2441dd3252cf53f12154412286ba0.jpg');
padding:50px;
}
#login-dp{
min-width: 250px;
padding: 14px 14px 0;
overflow:hidden;
background-color:rgba(255,255,255,.8);
}
#login-dp .help-block{
font-size:12px
}
#login-dp .bottom{
background-color:rgba(255,255,255,.8);
border-top:1px solid #ddd;
clear:both;
padding:14px;
}
#login-dp .social-buttons{
margin:12px 0
}
#login-dp .social-buttons a{
width: 49%;
}
#login-dp .form-group {
margin-bottom: 10px;
}
.btn-fb{
color: #fff;
background-color:#3b5998;
}
.btn-fb:hover{
color: #fff;
background-color:#496ebc
}
.btn-tw{
color: #fff;
background-color:#55acee;
}
.btn-tw:hover{
color: #fff;
background-color:#59b5fa;
}
#media(max-width:768px){
#login-dp{
background-color: inherit;
color: #fff;
}
#login-dp .bottom{
background-color: inherit;
border-top:0 none;
}
}
</style>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<body>
<nav class="navbar navbar-default navbar-inverse" role="navigation">
<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="#">Login dropdown</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">Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><p class="navbar-text">Already have an account?</p></li>
<li class="dropdown">
<b>Login</b> <span class="caret"></span>
<ul id="login-dp" class="dropdown-menu">
<li>
<div class="row">
<div class="col-md-12">
Login via
<div class="social-buttons">
<i class="fa fa-facebook"></i> Facebook
<i class="fa fa-twitter"></i> Twitter
</div>
or
<form class="form" role="form" method="post" action="login" accept-charset="UTF-8" id="login-nav">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Email address" required>
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password" required>
<div class="help-block text-right">Forget the password ?</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> keep me logged-in
</label>
</div>
</form>
</div>
<div class="bottom text-center">
New here ? <b>Join Us</b>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</body>
<script type="text/javascript">
</script>
</body>
</html>
Just you can do it in this way--
Add a class .navbar-centre to the ul which contains the links to be centered.
Then add the css like the snippet.
#media (min-width: 768px) {
.navbar-nav.navbar-center {
position: absolute;
left: 50%;
transform: translatex(-50%);
}
}
<html>
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-inverse" role="navigation">
<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="#">Login dropdown</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 navbar-center">
<li class="active">Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><p class="navbar-text">Already have an account?</p></li>
<li class="dropdown">
<b>Login</b> <span class="caret"></span>
<ul id="login-dp" class="dropdown-menu">
<li>
<div class="row">
<div class="col-md-12">
Login via
<div class="social-buttons">
<i class="fa fa-facebook"></i> Facebook
<i class="fa fa-twitter"></i> Twitter
</div>
or
<form class="form" role="form" method="post" action="login" accept-charset="UTF-8" id="login-nav">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Email address" required>
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password" required>
<div class="help-block text-right">Forget the password ?</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> keep me logged-in
</label>
</div>
</form>
</div>
<div class="bottom text-center">
New here ? <b>Join Us</b>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</body>
</html>
I'm attempting to preserve the position of two menu element (Home icon and Foo) that render as desired on large devices:
But are displayed as rows on a mobile device (obscuring content):
Is there a way to force these two menu items to display to the right of the Brand menu and on the same 'row'?
Sample: http://www.bootply.com/Fjq7ZXSDXc#
You can create a separate div inside the navbar-header: See example Snippet.
.navbar-header .nav-icons {
padding-top: 12px;
position: absolute;
display: inline-block;
top: 0;
}
.navbar-header .nav-icons span {
padding-left: 5px;
padding-right: 5px;
font-size: 20px
}
.navbar-header .nav-icons a {
color: #fff;
text-decoration: none;
}
<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" />
<nav class="navbar navbar-inverse navbar-static-top custom-navbar" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#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" rel="home" href="#" title="Help"> Brand</a>
<div class="nav-icons">
<a href="#"> <span class="glyphicon glyphicon-home"></span>
</a>
<a href="#"> <span> Foo</span>
</a>
</div>
</div>
<div class="navbar-collapse collapse" id="navbar-collapse-1">
<!-- Non-collapsing right-side icons -->
<ul class="nav navbar-nav navbar-right">
<li class="active">Home
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="text-center">
<h1>Bootstrap starter template</h1>
<p class="lead">Use this document as a way to quickly start any new project.
<br>All you get is this text and a mostly barebones HTML document.</p>
</div>
</div>
<!-- /.container -->
Try to add this in your .css
.nav-collapse .nav > li {
display: inline-block;
}
Basically I am trying to convert the bootstrap navbar into a tool bar. On that toolbar I added some btn-groups with dropdowns which work fine before the media query collapses it. Once it has been collapsed the dropdown-menus cannot be seen, although the element is there and it casts the shadow that it would if it were there. How do I get these drops downs to show up after the collapse?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> INDEX </title>
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="mycss/style.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="datepicker/js/bootstrap-datepicker.js"></script>
</head>
<body>
<nav class="navbar navbar-footer">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#footNav"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="#">Tool Bar</a>
</div>
<div class="collapse navbar-collapse" id="footNav">
<!-- 1st btn-group (No Dropdown) -->
<div class="btn-group" role="group" aria-label="..." style="margin-right: 7px">
<button type="button" class="btn btn-default">Yesterday</button>
<button type="button" class="btn btn-default">Today</button>
<button type="button" class="btn btn-default">Tomorrow</button>
</div>
<!-- 2st btn-group doesn't work after collapse -->
<div class="btn-group" role="group" aria-label="..." style="margin-right: 7px">
<div class="btn-group dropup" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Past
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Past</li>
<li>This</li>
<li>Next</li>
</ul>
</div>
<button type="button" class="btn btn-default">W</button>
<button type="button" class="btn btn-default">M</button>
<button type="button" class="btn btn-default">3M</button>
<button type="button" class="btn btn-default">Y</button>
</div>
<!-- 3rd btn-group doesn't work after collapse -->
<div class="dropup">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Date Range
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
<div class="input-group" style="padding-bottom: 4px;">
<span class="input-group-addon" >From:</span>
<input class="datepicker" style="height: 30px; width:120px; font-size: 18px; padding:10px;" name="startDate">
</div>
<div class="input-group">
<span class="input-group-addon" >To:</span>
<input class="datepicker2" style="height: 30px; width:120px; font-size: 18px; padding:10px;" name="endDate">
</div>
</ul>
</div>
</div>
</nav>
</body>
</html>
I use the standard bootstrap stuff with the exception of the css changes
/*Calendar tool Bar*/
.navbar {
border-radius: 0px;
}
.dropup{
display: inline-block;
}
.dropdown-menu .input-group .input-group-addon:first-child {
width: 63px;
}
.dropdown-menu {
padding: 4px 4px 4px 4px;
min-width: 30px;
}
.navbar-footer {
background-color: #f8f8f8;
border-color: #e7e7e7;
position: fixed;
bottom: 0px;
width: 100%;
margin-bottom: 0px;
vertical-align: middle;
}
.navbar-footer .navbar-toggle:hover,
.navbar-footer .navbar-toggle:focus {
background-color: #ddd;
}
.navbar-footer .navbar-toggle {
border-color: #ddd;
}
.navbar-footer .navbar-toggle .icon-bar {
background-color: #888;
}
button {
margin-top: 8px;
}
You just need to override the bootstrap .navbar-collapse.in class to make it visible even if it overflows vertically.
.navbar-collapse.in {
overflow-y: visible;
}
Working example.