full width navbar using bootstrap - html

I need to boorstrap full width navbar in 940px container and after header like this pic. How to ?
Code in jsfiddle

This is how you would do it in a "bootstrappy" way...
/* put the stuff you want NOT to span 100% in a container */
<div class="container">
/* wrap the grouping in a row */
<div class="row">
/* left center and right classes are unneeded.*/
/* Just used to show color in the fiddle */
<div class="span3 left">Header Left</div>
<div class="span6 center">Header Center</div>
<div class="span3 right">Header Right</div>
</div>
</div>
/* navbar outside the container will span 100% */
<div class="navbar">
<div class="container">
<div class="navbar-inner">
<div class="span12">
<a class="brand" href="#">Title</a>
<ul class="nav">
<li class="active">Home</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
</div>
</div>
</div>
/* back into a container so it doesn't span the full width */
<div class="container">
<div class="row">
<div class="span12 content">Content</div>
</div>
</div>
DEMO
EDIT: Updated to reflect requirements of navlinks inside container.

You need a container, to hold the header and the content.
For example:
<div class="container">
<div id="headerleft"></div>
<div id="header"></div>
<div id="headerright"></div>
</div>
<div id="nav"></div>
<div class="container">
<div id="content"></div>
</div>
And the CSS would be similar to this:
.container { width: 75%; }
#nav { width: 100%; }

Related

How can I make a column start top of container, and not depend on other columns?

I'm trying to make a grid-layout with BS4.
This is how it looks right now:
My grid-layout
This is what I'm trying to achieve: grid-layout I want
The problem I have is that my sidebar is starting at the same place as main content. I want it to start from the top along with the navbar. I know you can do this if you nest navbar and main content into the same column, but I don't want that since I'm going to make navbar into a partial.
HTML:
<div class="container">
<div id="wrapper">
<div class="row">
<div id="navbar" class="col-md-8">
Navbar
</div>
<div id="main" class="col-md-8">
Main Content
</div>
<div id="sidebar" class="col-md-4">
Sidebar
</div>
</div>
</div>
</div>
CSS:
#wrapper{
height: 200px;
width: 400px;
}
#navbar{
background-color: yellow;
height: 50px;
}
#main{
background-color: blue;
height: 200px;
}
#sidebar{
background-color: red;
}
JSfiddle link
You should try to group columns by putting navbar and main-content in one column and the second column for sidebar.
<div class="row">
<div class="col-8 col-md-8">
<div id="navbar" class="col-md-12">
Navbar
</div>
<div id="main" class="col-md-12">
Main Content
</div>
</div>
<div id="sidebar" class="col-4 col-md-4">
Sidebar
</div>
</div><--row-->
working fiddle

Two left-floating cols plus right-floating sidebar Bootstrap

My goal is to achieve the following image on my page:
I managed to achieve this with the HTML and CSS you can find below, but it doesn't seem very viable, because the sidebar is losing it's physical height because of the position: absolute.
I'm wondering if it's possible to make one row with two columns on the left and a sidebar on the right, without having to use positioning.
I tried position: relative with a negative top, but since the top col-md-9 has a changing height (depending on what is entered), I can't give it a negative top. It'll simply be too static and impossible to maintain.
Changing the order in the HTML doesn't change anything, since the physical height of the sidebar will move the 2nd content down.
.sidebar {
position: absolute;
width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-9">
Changing content
</div>
<div class="col-md-3 sidebar">
Sidebar
</div>
<div class="col-md-9">
More content
</div>
</div>
I use xs columns for this example, but you can change to md in your page.
Firstly create a 9-column and a 3-column div. Then put two divs inside the 9-column one.
.content, .sidebar {
margin: 10px;
padding: 20px;
}
.content {
background-color: navy;
color: white;
}
.sidebar {
background-color: yellow;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row wrapper">
<div class="col-xs-9">
<div class="row">
<div class="col-xs-12">
<div class="content">Content</div>
</div>
<div class="col-xs-12">
<div class="content">Content</div>
</div>
</div>
</div>
<div class="col-xs-3">
<div class="sidebar">Sidebar</div>
</div>
</div>
You can nest col-x-x inside other col-x-x
You just have to create 2 parents: content and sidebar, then add multiple contents into the content parent :
<div class="row">
<div class="col-md-9">
<div class="col-md-12">
Content
</div>
<div class="col-md-12">
More content
</div>
</div>
<div class="col-md-3 sidebar">
Sidebar
</div>
</div>
You cannot have more that 12 columns in a row unless it is not defined in your custom grid.
What you can try is this:
<div class="row">
<div class="col-md-9">
<div class="row">
<div class="col-sm-12">
Changing content
</div>
<div class="col-sm-12">
More content
</div>
</div>
</div>
<div class="col-md-3" style="position: relative;">
<div class="row">
<div class="col-sm-12 sidebar">
Sidebar
</div>
</div>
</div>
</div
As a solution, you can make sidebar to stay at the right side of screen if you'll make left section overflow: auto.
.sidebar {
height: 100vh;
background: lightgreen;
}
.left-section {
height: 100vh;
background: lightblue;
overflow: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-9 left-section">
<div class="row">
<div class="col-sm-12">
Changing content
</div>
<div class="col-sm-12">
More content
</div>
</div>
</div>
<div class="col-sm-3 sidebar">
Sidebar
</div>
</div>
</div>

How to remove space between bootstrap divs

I have three divs like this:
<div class="container-fluid">
<div class="header">
Welcome
</div>
<div class="navbar">
Menu
</div>
<div class="content">
Website content
</div>
</div>
Now, the first div class="container-fluid" is stretched on all browser window. The next class="header has padding/margin of some pixels from his parent element. Now I´d like this div to stretch all browser window out. But I also don´t want next class="menu" or class="content" to be stretched out.
How may I solve this?
Use .container for navbar and content & .row for .header like this: Demo
<div class="row">
<div class="header col-xs-12 col-sm-12 ">Welcome</div>
</div>
<div class="row">
<div class="container">
<div class="navbar">Menu</div>
<div class="content">Website content</div>
</div>
</div>
This sounds like a two-column layout with a full-width header. You tagged Twitter Bootstrap so I'll explain how to use those styles to do what you want.
<div class="row container-fluid">
<div class="header">
Welcome
</div>
<div class="span3 navbar">
Menu
</div>
<div class="span9 content">
Website content
</div>
</div>
The row class is on the element that wraps the columns. span# is the class that gives each column its size. So for a 12-unit width, you could assign span3 to the navbar and span9 to the content area.
Without Bootstrap, this is still relatively simple. You can do this in CSS.
.navbar {
display: inline-block;
width: 25%;
}
.content {
display: inline-block;
width: 75%;
}
<div class="container-fluid">
<div class="header">
Welcome
</div>
</div>
<div class="container">
<div class="navbar">
Menu
</div>
<div class="content">
Website content
</div>
</div>
Use container class outside menu and content. Hope this will help you.
jsFiddle Demo

separater and list-group from bootstrap are flowing through divs

My pen: http://codepen.io/helloworld/pen/yyoJGR
Why is the white separater and the list-grouping flowing through the divs or the parent row?
<div class="container columnStyle">
<div class="row">
<div class="row-same-height">
<div class="col-xs-3 col-xs-height">
<img class="img-responsive" src="http://s7.postimg.org/agarkavmj/whoiswho.png"></img>
</div>
<div class="col-xs-9 col-xs-height" >
<div class="container">
<div class="row">
<div class="page-header">
<h1>Who is who
<p>
<small>Organization & Processes</small>
</p>
</h1>
</div>
</div>
</div>
<div class="container">
<div class="row">
<ul class="list-group">
<li class="list-group-item">Org Charts </li>
<li class="list-group-item">GAM / KAM Charts</li>
<li class="list-group-item">Process flow</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
.columnStyle{
background: #006AB3;
}
Because you use the class .containermultiple times.
This class has a fixed width of 1170px;
.container {
width: 1170px;
}
you should have only 1 .containerfor the wrapper and then, inside of it, remove the other .container and just use .row
See it in action : http://codepen.io/anon/pen/ogeLRb

parent negative margin with nested floated divs wont follow the parent if object overlaps

Heh, sorry for the long title, but I need a fix for this and have been on it for some time now.
Basically there is a header and I'd like to move content underneath it.
Everything is relative (keeping it centered)
so header has a margin top, z-index, ecc.
The page is relative with a negative margin and contains nested floated columns that wont go up past the header (dammit) and cannot figure out why.
I would like to avoid using absolute positioning if possible.
Here's the code:
<div class="header wrapper-standard">
<div class="logo">
<div class="inside">hello</div>
</div>
<div class="menu-wrapper-outer">asda</div>
<div class="clear"></div>
</div>
<div class="about-page wrapper-standard notop">
<div class="about-page content">
<div class="about-block wrapper-long">
<div class="col col-left text-first">
asda
</div>
<div class="col col-right">
lol
</div>
<div class="clear"></div>
</div>
<div class="about-block wrapper-long">
<div class="col col-left text-first">
asda
</div>
<div class="col col-right">
lol
</div>
<div class="clear"></div>
</div>
<div class="about-block wrapper-long">
<div class="col col-left text-first">
asda
</div>
<div class="col col-right">
lol
</div>
<div class="clear"></div>
</div>
</div>
</div>
Here's the fiddle:
fiddle
Thanks.
Here is a very basic example of how you can have a fixed width, centered page with a fixed header which allows the content to flow underneath:
CSS:
<style type="text/css">
.wrapper{
height:600px;
margin:0 auto;
width:400px;
background-color:#0ff;
}
.header_wrapper {
position:fixed;
background-color:#ffd800;
}
.header {
width:400px;
background-color:#f00;
height:100px;
}
.page {
padding-top:100px; /*height of header*/
}
</style>
HTML:
<body>
<div class="wrapper">
<div class="header_wrapper">
<div class="header">Header</div>
</div>
<div class="page">
Content will be here bla bla etc
</div>
</div>
</body>
Here is a fiddle so that you can see it working: http://jsfiddle.net/JjBG5/1/