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?

thanks
LVL 25
dgrafxAsked:
Who is Participating?

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

x
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

http://jsbin.com/buqoli/1/edit?html,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>
</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.
http://jsbin.com/buqoli/2/edit
<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>  
</div>

Open in new window

or go to 2 columns for the xs size
http://jsbin.com/buqoli/3/edit
<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>  
</div>

Open in new window


The columns change based on media queries that have break points at <768px, >768px, >=992px, and >=1200px http://getbootstrap.com/css/#grid 

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 https://api.jquery.com/width/ 
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>width demo</title>
  <style>
  body {
    background: yellow;
  }
  button {
    font-size: 12px;
    margin: 2px;
  }
  p {
    width: 150px;
    border: 1px red solid;
  }
  div {
    color: red;
    font-weight: bold;
  }
  </style>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
 
<button id="getp">Get Paragraph Width</button>
<button id="getd">Get Document Width</button>
<button id="getw">Get Window Width</button>
<div>&nbsp;</div>
<p>
  Sample paragraph to test width
</p>
 
<script>
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() );
});
</script>
 
</body>
</html>

Open in new window

0

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:
Thanks
Q: what does the xs or the md stand for as in col-xs-10?
0
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 http://getbootstrap.com/css/#grid
0
dgrafxAuthor Commented:
Thanks a lot - I appreciate it!
0
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
CSS

From novice to tech pro — start learning today.