How can I place a div below a navbar - twitter-bootstrap-3

I need to place a div below my top navbar which should not scroll with the page content just like the navbar.
I've tried to create it as a second navbar but it is still scrolling or causing a blank area above the two navbars.
How can I do this?
UPDATE
In this sample the green bar is on top of the navbar, but I need it to stay below the navbar: http://jsfiddle.net/julianonunes/y8YqK/
If I move the green bar code (code sample below) before the navbar, it is hidden by the navbar.
Ex:
<div class="navbar navbar-decoration navbar-fixed-top"></div>
<div class="navbar navbar-default navbar-remote navbar-fixed-top">
<div class="navbar-header"> Brand
</div>
</div>

Ok. The problem is your second div includes 'navbar-fixed-top' which is glueing it to the top of your screen. You don't want it fixed to the top - you just want it fixed in place below the main navbar. Change your html for the second nag to:
<div class="navbar navbar-default navbar-remote navbar-decoration ">
And add to your navbar-decoration class:
width: 100%
position: fixed;

You may have tried this already, but in the css for the second navbar put
position: fixed;
If you don't want to add to your stylesheet, you can put it in the div like this:
<div style="position: fixed;"> </div>
I am not sure, but you may also have to add display:block like this:
<div style="position: fixed; display: block;"> </div>
With Bootstrap, use this logic within their html/css:
<div class="navbar" style="position: fixed; display: block;">
<div class="navbar-inner">
<a class="brand" href="#">Title</a>
<ul class="nav">
<li class="active">Home</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
</div>
My last guess:
<div class="navbar" style="margin-top: 10px;">
<div class="navbar-inner">
<a class="brand" href="#">Title</a>
<ul class="nav">
<li class="active">Home</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
</div>
Hope one of those works.

I've got it fixed by adding margin-top to the second navbar with navbar-fixed-top.
<div class="navbar navbar-default navbar-remote navbar-fixed-top">
<div class="navbar-header"> Brand
</div>
</div>
<div class="navbar navbar-decoration navbar-fixed-top"></div>
CSS
.navbar-decoration {
margin-top: 50px;
min-height: 5px;
max-height: 5px;
/* ... */
}

Related

Bootstrap accordion icons not working on collapsed states

I am working on a accordion in Bootstrap V 3.37. I have icons on the accordion which change with open and closed states. When I the state set to collapse init works fine. But when I have the accordion with none of them accordions collapsed in the icons are not working properly.
The icons should be working as:
Arrow facing down on closed state
Arrow facing up on open state
My code is as follows so far:
HTML Structure
<!-- Panel list accordion -->
<div class="panel-group">
<div class="panel-heading-one panel-main-heading-one">
<h4 class="panel-title panel-main-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
<img src="../images/image.svg" class="panel-icon">
<p>Title here</p>
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body panel-bodymain-one">
<p>Text body here</p>
</div>
</div>
<div class="panel-heading-one panel-main-heading-one">
<h4 class="panel-title panel-main-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
<img src="../images/image.svg" class="panel-icon">
<p>Title here</p>
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body panel-bodymain-one">
<p>Title body here</p>
</div>
</div>
<div class="panel-heading-one panel-main-heading-one">
<h4 class="panel-title panel-main-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
<img src="../images/image.svg" class="panel-icon">
<p>Title here</p>
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body panel-bodymain-one">
<p>Text body here</p>
</div>
</div>
</div>
</div>
<!-- End panel list accordion -->
CSS
.panel-heading-one .accordion-toggle:after {
/* symbol for "opening" panels */
font-family: 'Glyphicons Halflings';
content: "\e113";
float: right;
color: #ffffff;
height: 24px;
width: 40px;
background-color: #000000;
}
.panel-heading-one .accordion-toggle.collapsed:after {
/* symbol for "collapsed" panels */
content: "\e114";
}
Screenshots attached also.
Closed state - still point up:
Open state is fine as it points up:
Any help would be great.
Change your css to:
.panel-heading-one .accordion-toggle:after{
font-family: 'Glyphicons Halflings';
content: "\e114";
float: right;
color: #ffffff;
height: 24px;
width: 40px;
background-color: #000000;
}
.panel-heading-one .accordion-toggle[aria-expanded="true"]:after {
/* symbol for "opening" panels */
content: "\e113";
}
.panel-heading-one .accordion-toggle[aria-expanded="false"]:after {
/* symbol for "collapsed" panels */
content: "\e114";
}
And it will work perfectly.
Extra: In your accordion you have used same href='#collapseThree'
for last and second last item. When you will click on last element, it
will open second last item. So change your href in last element.

Cannot bottom align image in jumbotron

I'm trying to bottom align an img in a jumbotron, but cannot figure it out.
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-lg-8">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="col-lg-4 text-center">
<img src="http://via.placeholder.com/200x200">
</div>
</div>
</div>
</div>
I tried adding the following to the CSS
.vertical-bottom {
display: flex;
align-items: bottom;
}
And then added the additional class to the DIV containing the img
<div class="col-lg-4 text-center vertical-bottom">
This didn't work, why is it so hard to vertically align things in bootstrap?
Here a kind of code:
Bootply
Css:
The media query is set to 1200 because I see you're using col-lg-xx
#media screen and (min-width:1200px) {
.flex_container img{
object-fit: contain;
object-position: 100% 100%;
}
.flex_container {
display: flex;
}
}
Html:
<div class="jumbotron">
<div class="container">
<div class="row flex_container">
<div class="col-lg-8">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="col-lg-4 text-center flex_container">
<img src="http://via.placeholder.com/200x200" style="">
</div>
</div>
</div>
</div>

Align 11 columns on bootstrap, how to deal with missing column?

I have a grid with 11 columns
<div class="row">
<div class="col-lg-1">1</div>
<div class="col-lg-1">2</div>
<div class="col-lg-1">3</div>
<div class="col-lg-1">4</div>
<div class="col-lg-1">5</div>
<div class="col-lg-1">6</div>
<div class="col-lg-1">7</div>
<div class="col-lg-1">8</div>
<div class="col-lg-1">9</div>
<div class="col-lg-1">10</div>
<div class="col-lg-1">11</div>
</div>
My problem is that bootstrap works on 12 column grids, therefore the 12th column shows empty. (making the grid look non centered)
I want to center this grid so at the beginning of the grid there will be the space of half a column, and at the end of the grid it will show the other half:
<div class="row">
<div class="col-lg-1/2">1/2 blank</div>
<div class="col-lg-1">1</div>
<div class="col-lg-1">2</div>
<div class="col-lg-1">3</div>
<div class="col-lg-1">4</div>
<div class="col-lg-1">5</div>
<div class="col-lg-1">6</div>
<div class="col-lg-1">7</div>
<div class="col-lg-1">8</div>
<div class="col-lg-1">9</div>
<div class="col-lg-1">10</div>
<div class="col-lg-1">11</div>
<div class="col-lg-1/2">1/2 blank</div>
</div>
^ thats an example of how I imagine it will work, but unfortunately we dont have 1/2 columns on boostrap.
You could always create a half-size column to add into a supplemental style sheet (You'll want to make sure you account for all of the styling, though):
.col-lg-half {
width: 4.166666665%;
}
.col-lg-half
{
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
#media (min-width: 1200px) {
.col-lg-half {
float: left;
}
}
Then, what you are wanting should work.
<div class="row">
<div class="col-lg-half">1/2 blank</div>
<div class="col-lg-1">1</div>
<div class="col-lg-1">2</div>
<div class="col-lg-1">3</div>
<div class="col-lg-1">4</div>
<div class="col-lg-1">5</div>
<div class="col-lg-1">6</div>
<div class="col-lg-1">7</div>
<div class="col-lg-1">8</div>
<div class="col-lg-1">9</div>
<div class="col-lg-1">10</div>
<div class="col-lg-1">11</div>
<div class="col-lg-half">1/2 blank</div>
</div>

Image is not responsive with class added

as the title says. Here is the code I'm using this theme http://startbootstrap.com/template-overviews/grayscale/
Edit where is the whole code to make it clear:
<nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
<i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top">
<!-- <i class="fa fa-play-circle"></i> <span class="light">Start</span> Bootstrap -->
<img class="img-responsive" src="img/ssmk_logo.png">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<!-- Hidden li included to remove active class from about link when scrolled up past about section -->
<li class="hidden">
</li>
<li>
<a class="page-scroll" href="#weather">Weather Forecast</a>
</li>
<li>
<a class="page-scroll" href="#download">Estate Agent</a>
</li>
<li>
<a class="page-scroll" href="#contact">Stocks</a>
</li>
<li>
<a class="page-scroll" href="#about">About Us</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
Should the objective be to get your logo into the Bootstrap navbar, you'll have to resize the image in some way. Your options for that are to do it with CSS, or to make a smaller version of it to be served up to your site. My solution resizes it using CSS.
img {
margin-top: -11px;
height: 40px;
width: 45px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" src="http://i.imgur.com/9PRm767.png" />
</a>
</div>
</div>
</nav>
Per the documentation for Bootstrap nav branding using images, this is how you add an image to your navbar instead of text for branding purposes. The documentation also says you'll need to either override some CSS depending on your image. My CSS here gets rid of some of the margin the navbar-header creates so the image is nice and flush with the rest of the navbar. Should you want a larger image to be used, you'll need to mess with the width of your navbar.
Using the img-responsive class from Bootstrap is not appropriate here due to the widths of various components in the navbar for Bootstrap, which only collapses down in smaller viewports and does not, itself, dynamically resize along all dimensions as the viewport gets wider. The Bootstrap navbar is easily the most inflexible item in the entire framework, but that's not a bad thing because really, you shouldn't be messing with the size of the navbar too much.
UPDATE
With the correct closing tags that should work. As you can see if you resize Maradona image, it appears to be responsive. I suggest you to validate your entire HTML and check if there is some error on it.
http://jsfiddle.net/xd1p8pov/
Your html (as we see it) is missing one div and one nav closing tags. Have you tried to inspect the .img-responsive class? By default in Bootstrap should be :
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}

Having trouble with fixed navbar not getting parrent width?

I've recently started working with bootstrap and is somewhat a newbie to webdesign as well.
I've been having trouble with my navbar not enheriting the .container-fluid width, which in the end making in non-responsive. I wanted my navbar to be fixed and in "high" z-position, to overlap content. I've been searching far and low on Stack Overflow to find an answer but with no luck. Can some wiz please enlighten me?
I don't have the exact code currently but it look something like:
<div class="container-fluid">
<div class="navbar">
<ul class="nav nav-pills" id="navbar">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
CSS
#navbar{
position:fixed;
z-index:999;
background-color: rgba(0,0,0,0.7);
}
There is a CSS Class(navbar-fixed-top) in bootstrap for a fixed navbar.
Change your first <div> to <nav> (nav is a div but it is the HTML5 standard)
Add the navbar-default & navbar-fixed-top to your <nav>
Nest your container-fluid div inside your <nav>...</nav>
Add link tags to your <li> items
HTML:
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<ul class="nav nav-pills" id="navbar">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</nav>
Then you will need to add padding to your body in your CSS file if you dont want the navbar to overlap content:
CSS:
body{
padding-top: 70px;
}
Documentation here
I hope this helps!