seven column bootstrap layout

1. how would one create a seven column bootstrap layout?

2. how can i detect when columns have decreased to 1 column?

LVL 25
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
The key is everything needs to add up to 12.  At minimum you can everything col-xs-1.  Or adjust some columns wider as long as they add up to 12,output
<div class="row">
<div class="col-xs-2 red">one</div>  
  <div class="col-xs-1 blue">two</div>  
  <div class="col-xs-2 green">three</div>  
  <div class="col-xs-3 purple">four</div>  
  <div class="col-xs-1 black">five</div>  
  <div class="col-xs-2 red">six</div>  
  <div class="col-xs-1 purple">seven</div>

Open in new window

But this goes against the reason to use bootstrap and you will see that 7 columns is too many for the xs size screen especially when you have some columns wider than col-xs-1.

The better way would be to make your seven columns for the next bigger size screen and let the xs go to one column.
<div class="row">
  <div class="col-sm-2 red">one</div>  
  <div class="col-sm-1 blue">two</div>  
  <div class="col-sm-2 green">three</div>  
  <div class="col-sm-3 purple">four</div>  
  <div class="col-sm-1 black">five</div>  
  <div class="col-sm-2 red">six</div>  
  <div class="col-sm-1 purple">seven</div>  

Open in new window

or go to 2 columns for the xs size
<div class="row">
  <div class="col-xs-6 col-sm-2 red">one</div>  
  <div class="col-xs-6 col-sm-1 blue">two</div>  
  <div class="col-xs-6 col-sm-2 green">three</div>  
  <div class="col-xs-6 col-sm-3 purple">four</div>  
  <div class="col-xs-6 col-sm-1 black">five</div>  
  <div class="col-xs-6 col-sm-2 red">six</div>  
  <div class="col-xs-6 col-sm-1 purple">seven</div>  

Open in new window

The columns change based on media queries that have break points at <768px, >768px, >=992px, and >=1200px 

The classes will work on their own so there is no reason to do any detection.  If you need to do something in javascript then you can detect the width using jquery or javascript.  In jquery 
<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>width demo</title>
  body {
    background: yellow;
  button {
    font-size: 12px;
    margin: 2px;
  p {
    width: 150px;
    border: 1px red solid;
  div {
    color: red;
    font-weight: bold;
  <script src=""></script>
<button id="getp">Get Paragraph Width</button>
<button id="getd">Get Document Width</button>
<button id="getw">Get Window Width</button>
  Sample paragraph to test width
function showWidth( ele, w ) {
  $( "div" ).text( "The width for the " + ele + " is " + w + "px." );
$( "#getp" ).click(function() {
  showWidth( "paragraph", $( "p" ).width() );
$( "#getd" ).click(function() {
  showWidth( "document", $( document ).width() );
$("#getw").click(function() {
  showWidth( "window", $( window ).width() );

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dgrafxAuthor Commented:
Q: what does the xs or the md stand for as in col-xs-10?
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
xs= extra small, sm = small, md=medium, lg = large.  The code below will render the div to be 50% on a extra small screen (6 columns out of 12) and it will be 16.6% wide on a small screen (2 columns out of 12).

 <div class="col-xs-6 col-sm-2 red">one</div>  

Open in new window

Read up on the how this works so it will be second nature to you.  This is the most important part of bootstrap
dgrafxAuthor Commented:
Thanks a lot - I appreciate it!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.