Im currently trying to make the bottom of two divs, a title and a navbar, to line up vertically, but I'm having a bit of trouble figuring out how to make that work. vertical-align:bottom in the CSS doesn't seem to work. To clarify, I want the "GOT/IT" text and the nav bar text elements to line up vertically (bottom). The code is shown here:
.navbar-default {
padding-top: 65px;
padding-left: 45px;
padding-right: 45px;
margin-left: 0px;
margin-right: 0px;
border-radius: 0px;
border-bottom: 10px solid #2e9eed;
}
.header-text {
font-size: 64px;
color: blue;
position: relative;
padding-bottom: 20%;
}
.header-item-text {
background-color: green;
font-size: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row">
<nav class="navbar navbar-default">
<!-- 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 class="navbar-brand" href="#"><span class = "header-text">GOT/IT</span></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<!-- Desktop + Tablet View -->
<div class="hidden-xs">
<div class="pull-right collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="header-item-text">THE WHY
</li>
<li class="header-item-text">THE WHAT
</li>
<li class="header-item-text">VALIDATE
</li>
<li class="header-item-text">ABOUT
</li>
<li class="header-item-text">CONTACT
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
I am assuming you are trying to vertically align the bottom of two columns. You can try using a table for this like the following:
<table >
<tr>
<td style="vertical-align:bottom">
<div>
....
....
</div>
</td>
<td style="vertical-align:bottom">
<div>
....
....
</div>
</td>
</tr>
</table>
You can give equal padding-left to both div.
I would suggest use bootstrap CSS.
You can also use HTML table tags.
Related
I'm using a fixed navbar on my website. The problem I have right now is whenever I increase the height of the logo, the logo goes outside parent navbar. I'm wanting to change that behavior so that navbar increases its height to adapt to new children height so that logo stays contained.
.logo {
max-height: 75px;
padding: 1%;
padding-top:2.35%;
}
.navbar-brand {
padding: 0px !important;
}
.navbar-brand .logo{
display:inline !important;
}
.navabar-custom{
background: black !important;
/*opacity:0.8;*/
}
.navabar-custom a{
color:white !important;
}
.icon-bar{
background:white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top navabar-custom" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<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 href="" class="navbar-brand" href="index.php">
<img class="logo" alt="logo" src="https://upload.wikimedia.org/wikipedia/commons/4/41/SEGA_logo.png">
</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-right">
<li>
About Us
</li>
<li>
Contact Us
</li>
<li class="dropdown">
Services
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
.navbar-brand (parent of .logo) has fixed height of 50px. Just set it to auto
.logo {
max-height: 75px;
padding: 1%;
padding-top:2.35%;
}
.navbar-brand {
padding: 0px !important;
height: auto !important; /******* add this *******/
}
.navbar-brand .logo{
/*display:inline !important;*/
/* this is not needed */
}
.navabar-custom{
background: black !important;
/*opacity:0.8;*/
}
.navabar-custom a{
color:white !important;
}
.icon-bar{
background:white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top navabar-custom" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<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 href="" class="navbar-brand" href="index.php">
<img class="logo" alt="logo" src="https://upload.wikimedia.org/wikipedia/commons/4/41/SEGA_logo.png">
</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-right">
<li>
About Us
</li>
<li>
Contact Us
</li>
<li class="dropdown">
Services
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
Currently I'm learning Bootstrap 3 and I need help with re-order the layout of navbar in small screen.
I've followed the example in LINK
I've replaced Default / Static / Fixed with user profile
So what I want to change is when the screen is small I will have
|---------- BRAND ----------|
|[-]----------------------profile|
Here is my sample code:
#media (max-width: 767px) {
.navbar-brand {
width: auto;
float: none;
border-bottom: 0 solid transparent;
margin: 0 -15px;
}
.navbar-toggle {
float: left;
}
.nav-user-profile .navbar-nav {
margin: 0;
}
.nav-user-profile .navbar-nav>li {
position: static;
float: left;
}
.nav-user-profile .navbar-nav>li>a {
padding-top: 15px;
padding-bottom: 15px;
line-height: 20px;
}
}
<nav role="navigation" class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-brand">Brand</div>
<div class="navbar-header">
<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>
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
<div class="nav-user-profile navbar-right">
<ul class="nav navbar-nav">
<li>Profile</li>
</ul>
</div>
</div>
</nav>
How can I achieve it?
Thanks for ideas
I think this is what you're trying to do based on your diagram. Probably the simplest way to go is to create a div above the navbar for a second brand location. You can hide one or the other brand location with a hidden/visible class. And the profile link can be placed inside the navbar-header so it's visible across all viewports, it just needs to be positioned correctly on the right and the navbar-toggle floated to the left.
See working Snippet.
header {
text-align: center;
background: #f5f5f5;
width: 100%;
height: 50px;
padding: 15px 15px;
}
header .header-brand {
color: #777;
font-size: 18px;
line-height: 20px;
}
header .header-brand:focus,
header .header-brand:hover {
text-decoration: none;
color: #5e5e5e;
}
.navbar .btn.profile-btn,
.navbar .btn.profile-btn:hover,
.navbar .btn.profile-btn:focus {
float: right;
right: 0;
position: absolute;
margin-top: 10px;
background: none;
border: none;
}
#media (max-width: 767px) {
.navbar .navbar-toggle {
float: left;
margin-left: 15px;
}
}
<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" />
<header class="visible-xs-block"> <a class="header-brand" href="#">Brand</a>
</header>
<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-nav" 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 hidden-xs" href="#">Brand</a>
<button type="button" class="btn btn-default profile-btn">Profile</button>
</div>
<div class="collapse navbar-collapse" id="bs-nav">
<ul class="nav navbar-nav navbar-left">
<li class="active">Home
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</nav>
I only added text-right very simple look where I noted with //changes*
<nav role="navigation" class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-brand">Brand</div>
<div class="navbar-header">
<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>
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
//changes*
<ul class="nav navbar-nav text-right">
//changes*
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
<div class="nav-user-profile navbar-right">
<ul class="nav navbar-nav">
<li>Profile</li>
</ul>
</div>
</div>
</nav>
pull-right class may help you...
or
bootstrap is divided to 12 columns for large, medium and small size
So when it breaks into small size give brand to full 12 columns using col-sm-12 class so it will break profile to down
Can someone have a look to this fiddle http://jsfiddle.net/pkcwtone/1/ and tell me why I am not able to put the image all right inside the navigation?
This is html:
<nav id="mainNavigation" class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Responsive navigation -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-2"> <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 src="http://s28.postimg.org/gc8ajkjq5/advance_logo.png" alt=""/>
</a>
</div>
<div class="clearfix"></div>
<div class="collapse navbar-collapse" id="navbar-collapse-2">
<!-- top navigation-->
<ul class="nav navbar-nav navbar-left">
<li>
Home
</li>
<li>
Accident<br>Management
</li>
<li>
Approved<br>Manufacturers
</li>
<li>
Our<br>Services
</li>
<li>
About<br>Advance
</li>
<li>
Contact<br>Us
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
This is css:
#mainNavigation.navbar-default{
/*background: #f9540a;*/
background:black;
width: 100%;
text-align: center;
font-family:'Droid Sans', sans-serif;
font-weight:700;
font-size:1.2em;
}
#mainNavigation.navbar-header {
float: left;
padding: 15px;
text-align: center;
width: 100%;
}
#mainNavigation .container-fluid{
height:auto;
overflow:auto;
}
.navbar-brand img{
float:left;
}
I've been playing with overflow... with clearfix..... with the height.... but it looks bad :S The text overlays the logo, which it shouldn't (I know I could use padding, but I've though it must be a way more natural to keep in mind the space that the logo occupies), and then, the logo look cut! :S
Anyone can see what am I doing wrong?
Cheers :)
Looks like the issue is here:
#mainNavigation.navbar-header {
what the above css is looking for is a div with id mainNavigation and class nav-header
however you add a space between them, it looks for the class within the mainNavigation:
#mainNavigation .navbar-header {
you will be able to resize the navbar to fit the logo, see the updated jsfiddle:
http://jsfiddle.net/pkcwtone/4/
So I have this issue, I'm trying to get the navbar-toggle to get up into the corner but it's over lapping.
I also have a icon in pc view that over lapping which I really like.
Is there a way to fix the navbar-toggle??
My code is below.
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top">
<img class="visible-xs img-rounded pull-right" src="smallicon2.png" alt="" >
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-brand page-scroll">
<button type="button" class="navbar-toggle pull-left" 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>
<img src="icon2.png" class="img-rounded hidden-xs" />
</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-right">
<li class="hidden">
</li>
<li>
<a class="page-scroll" href="#">Home</a>
</li>
<li>
<a class="page-scroll" href="#services">Services</a>
</li>
<li>
<a class="page-scroll" href="#portfolio">Portfolio</a>
</li>
<li>
<a class="page-scroll" href="#about">About</a>
</li>
<li>
<a class="page-scroll" href="#contact">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
Thanks for looking.
In bootstrap CSS, Following causing the issue padding: 15px;
.navbar-brand {
float: left;
height: 50px;
padding: 15px;
font-size: 18px;
line-height: 20px;
}
This may fix the issue padding: 0px 15px; but it will effect the logo too
.navbar-brand {
float: left;
height: 50px;
padding: 0px 15px;
font-size: 18px;
line-height: 20px;
}
Fiddle
Proper Fix without effecting the logo, change margin-top: 8px; to margin-top: -5px; to following CSS in bootstrap css file
.navbar-toggle {
position: relative;
float: right;
padding: 9px 10px;
margin-top: -5px; <<<< Here
margin-right: 15px;
margin-bottom: 8px;
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
Fiddle
Note: Better approach do not edit bootstrap css, make customstyle.css and add above css with !important rule in custom css.
Don't waste your time with fixing. Copy and paste the complete navbar from Bootstrap navbar. After that, delete HTML you don't need, correctly!
The problem often begins if you want to have a navbar with a bigger logo.
Here is a precise instruction how to create a Bootstrap navbar with a bigger logo.
I am having trouble getting bootstrap 3's navabar to be responsive on a mobile device. The navbar continues to span further than the mobile display, and I cannot figure out what I did wrong.
The Code:
(HTML)
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar">
<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 img-responsive" href="index.html">
<img src="img/logo.png" width="320" height="85" alt="">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navigationbar">
<ul class="nav navbar-nav navbar-right">
<li>
Home
</li>
<li>
Getting Started
</li>
<li class="dropdown">
Products <b class="caret"></b>
<ul class="dropdown-menu">
<li>
Brain Seedâ„¢
</li>
</ul>
</li>
<li>
About Us
</li>
<li>
FAQ
</li>
<li>
Contact Us
</li>
<li>
<button type="button pull-right" class="btn btn-success">ORDER NOW</button>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
The Code: (CSS)
.navbar-fixed-top .nav {
padding: 20px 0;
}
.navbar-fixed-top .navbar-brand {
padding: 0 15px;
}
.page-content {
padding-top: 40px;
}
.img-center {
display: block;
margin: 0 auto;
}
.navbar .brand {
max-height: 40px;
max-width: 30%;
overflow: visible;
padding-top: 0;
padding-bottom: 0;
}
I notice you in your html code, you typed fixed height and width, which cancels the img-responsive class.
Start by removing that and go from there...enter link description here