how to create 8 even columns in Bootstrap 3 with out gutter - css

I'm trying to create a custom row which has 8 logos sat in even columns at the bottom of a page when sat at full size desktop (lg) I need them to work responsively.
I've tried a few options - 2 cols with 4 cols nested and 4 cols with 2 cols nested... the problem I have is the gutter creates extra spacing between columns which means the logos won't space evenly. Any experts have a better idea how I could place 8 logos spaced evenly in a row? perhaps creating a new 8 col custom grid?
Any help would be great.
Thanks
N

Bootstrap 3
How about using a list-inline with 4 columns of 2 like this..
<ul class="list-inline row">
<li class="col-sm-3"><div class="col-sm-6"></div><div class="col-sm-6"></div></li>
<li class="col-sm-3"><div class="col-sm-6"></div><div class="col-sm-6"></div></li>
<li class="col-sm-3"><div class="col-sm-6"></div><div class="col-sm-6"></div></li>
<li class="col-sm-3"><div class="col-sm-6"></div><div class="col-sm-6"></div></li>
</ul>
Demo: http://bootply.com/90906
Bootstrap 4
Since Bootstrap 4 is flexbox, any number of equal width columns is now possible using the auto-layout grid..
<div class="container-fluid">
<div class="row">
<div class="col">1</div>
<div class="col">2</div>
<div class="col">3</div>
<div class="col">4</div>
<div class="col">5</div>
<div class="col">6</div>
<div class="col">7</div>
<div class="col">8</div>
</div>
</div>
Demo: http://www.codeply.com/go/AOVGoJncei

2 columns 6 with each 4 colums 3 inside row-fluid
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
</div>
</div>
</div>

Extending on my answer here: https://stackoverflow.com/a/25023129/2266157
Here is a demonstration of an eight-wide Bootstrap row structure, with
Equal padding (i.e. column gutters)...
<div class="container">
<h2>No padding (.no-pad) on outermost columns (.col-md-6)<br></h2>
<h3>Then nested columns can have padding...</h3>
<div class="row no-pad">
<div class="col-md-6">
<div class="row">
<div class="col-md-3"><i>col1</i></div>
<div class="col-md-3"><i>col2</i></div>
<div class="col-md-3"><i>col3</i></div>
<div class="col-md-3"><i>col4</i></div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-3"><i>col1</i></div>
<div class="col-md-3"><i>col2</i></div>
<div class="col-md-3"><i>col3</i></div>
<div class="col-md-3"><i>col4</i></div>
</div>
</div>
</div>
</div>
...or indeed no column gutters.
<div class="container">
<h3>...or not</h3>
<div class="row no-pad">
<div class="col-md-6">
<div class="row no-pad">
<div class="col-md-3"><i>col1</i></div>
<div class="col-md-3"><i>col2</i></div>
<div class="col-md-3"><i>col3</i></div>
<div class="col-md-3"><i>col4</i></div>
</div>
</div>
<div class="col-md-6">
<div class="row no-pad">
<div class="col-md-3"><i>col1</i></div>
<div class="col-md-3"><i>col2</i></div>
<div class="col-md-3"><i>col3</i></div>
<div class="col-md-3"><i>col4</i></div>
</div>
</div>
</div>
</div>
This CSS is required in addition to Bootstrap
.row.no-pad {
margin-right:0;
margin-left:0;
}
.row.no-pad > [class*='col-'] {
padding-right:0;
padding-left:0;
}
Here is a working demo:http://www.bootply.com/eWWpj3G9tL
And the logo centring
To position the logos, I'd either use an <img class="img-responsive"> or if they're smaller than the column width then you could CSS center them with text-align:center (or the bootstrap class text-center placed on the .col-*) or using the following CSS:
#logos img {
display:block;
margin:0 auto;
}

Sounds like this is for a specific module so I would just create a simple new grid for this...
.eightLogos .logo {
float: left;
width: 12.5%;
margin: 0;
padding: 0;
}

Its Simple... Just add another column to your css.
Its best not to edit bootstrap CSS (and use a cdn).
So... We need to create the column css for all screen types.
I usually address 3 screen sizes which means creating 3 css sets for this column
big screens & normal screens
medium screens (ipad ext.)
small screens (mobile phones ext.)
Decision time:
Since we are talking about 8 columns which is a lot
its best to go with these css rules (in my opinion)
i almost always use a .container class for my designs which
makes big screen mode suitable in tablet unless in portrait mode.
In short, Here are a good set of css rules
/* Extra Small Devices, Phones */
#media only screen and (min-width : 480px) {
eight-col {width: 50%; padding: 0 15px;}
}
/* Small Devices, Tablets */
#media only screen and (min-width : 768px) {
eight-col {width: 20%; padding: 0 15px;}
}
/* Medium Devices, Desktops */
#media only screen and (min-width : 992px) {
eight-col {float: left; width: 12.5%; margin: 0; padding: 0 5px;}
}
Please note:
i play around with padding as i see fit. Its best to leave some extra padding when in mobile mode but you can play around with it ;)

Related

Order and stack 3 columns with bootstrap 4

I have this structure in bootstrap columns:
And I want you to change to a lower resolution, be ordered as follows:
I found how to do it with flexbox here:
Flexbox: reorder and stack columns
But I can not change the entire structure of my project to flexbox, so I want to know if with bootstrap 4, it is possible to do so.
Thank you very much.
My poor test.
#import url( 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css' );
div {
text-align: center;
height: 60px;
}
#left {
background: yellow;
}
#middle {
background: blue;
}
#right {
background: coral;
}
<div class="container">
<div class="row">
<div class="col-sm-3 col-md-3">
<div id="left">COLUMN 1</div>
</div>
<div class="col-sm-6 col-md-6">
<div id="middle">COLUMN 2</div>
</div>
<div class="col-sm-3 col-md-3">
<div id="right">COLUMN 3</div>
</div>
</div>
</div>
You can use the Bootstrap 4 (alpha 6) utility classes to avoid the extra CSS. 1-2-3 becomes 3-2-1 on mobile.
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-6 push-md-3">
<div id="middle">COLUMN 2</div>
</div>
<div class="col-sm-4 col-md-6">
<div class="row">
<div class="col-md-6 pull-md-12 flex-last flex-md-unordered">
<div id="left">COLUMN 1</div>
</div>
<div class="col-md-6">
<div id="right">COLUMN 3</div>
</div>
</div>
</div>
</div>
</div>
http://codeply.com/go/GIcPuzURbs
I assume by "resolution" you mean smaller screen size?
Here's a possible solution that uses some bootstrap push/pull grid utilities to reorder the columns in a medium size viewport, and then rearrange the layout in small size viewport the way you've shown in your diagram. In the small screen view, within a media query I use the css property order to reorder the 1 and 3 columns vertically Hope it gets you on the right track
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-6 push-md-3">
<div id="middle">COLUMN 2</div>
</div>
<div class="col-sm-4 col-md-6">
<div class='row'>
<div id='leftcont' class="col-md-6 pull-md-12">
<div id="left">COLUMN 1</div>
</div>
<div id='rightcont' class="col-md-6">
<div id="right">COLUMN 3</div>
</div>
</div>
</div>
</div>
</div>
CSS:
div {
text-align:center;
height:60px;
}
#left{background:yellow;}
#middle {background:blue;}
#right {background:coral;}
#media (max-width: 768px) {
#leftcont { order: 2; }
#rightcont {
order: 1;
margin-bottom: 1em; }
}
New fiddle
The height of the divs might have to be adjusted for grid breakpoints but since the colored divs were only for a test, i didn't match those to your example
have you tried to pull column 2 for lower resolution?

How does Bootstrap Pull and push work

I am trying to fix a page which wasn't bootstrapped like the illustration. But my col-2, col-3, col-4 don't align with the col 1 and 2. I cannot really understand how pull and push work. I have worked on my mobile layout and it seem fine, but as it goes to desktop, it messing the layout.
My layout becomes this, when I make it go desktop. Misaligned headings and columns under it.
You need to include yellow div-s into row so they won't jump over next line.
.left-box {
height: 290px;
width: 100%;
background: #e66;
margin: 3px;
}
.right-box {
height: 70px;
background: #ee6;
margin: 3px;
}
#media screen and (min-width: 992px) {
.left-box, .right-box {
height: 200px;
}
}
<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-md-2 col-xs-5">
<div class="left-box"></div>
</div>
<div class="col-md-10 col-xs-7">
<div class="row">
<div class="col-md-3"><div class="right-box"></div></div>
<div class="col-md-3"><div class="right-box"></div></div>
<div class="col-md-3"><div class="right-box"></div></div>
<div class="col-md-3"><div class="right-box"></div></div>
</div>
</div>
</div>
</div>
Note: according to bootstrap rules, the statement class="col-md-2 col-sm-5" is the same that class="col-lg-2 col-md-2 col-sm-5 col-xs-12".
Actually you don't need push-pull classes I think. You could use a markup like this:
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="left-box"></div>
</div>
<div class="col-md-6">
<div class="right-box"></div>
<div class="right-box"></div>
<div class="right-box">etc...</div>
</div>
</div>
</div>
Pen: http://codepen.io/anon/pen/yVKgwG

Reordering 3 Columns in Bootstrap for SEO

I need help reordering columns in Bootstrap for SEO purposes using push and pull. The final output would be like the image below. Right now I only need to switch the Left Sidebar and Main Content on desktop view. I managed to do this using a bunch of divs and floats but I decided to give bootstrap a try. Thanks!
HTML
<div class="container">
<div class="row">
<div class="col-sm-4 col-1 my-col">
Main Content (Middle)
</div>
<div class="col-sm-4 col-2 my-col">
Left Sidebar
</div>
<div class="col-sm-4 col-3 my-col">
Right Sidebar
</div>
</div>
</div>
CSS
.my-col{
line-height: 40px;
color:white;
text-align:center;
font-size: 20px;
}
.col-1{background:red}
.col-2{background:blue}
.col-3{background:green}
#media (min-width: 768px) {
.my-col{
line-height: 80px;
}
}
Bootply http://www.bootply.com/slW117V1oH#
Column ordering is the inbulit feature of bootstrap framework. For more information visit here
<div class="row">
<div class="col-md-9 col-md-push-3">.col-md-9 .col-md-push-3</div>
<div class="col-md-3 col-md-pull-9">.col-md-3 .col-md-pull-9</div>
</div>
example here codepen
enjoy :)

Bootstrap 12 colums of size 1 on extra small screen dont fiit

Hello I am trying to do what the title says, but in a small screen (like my phone) the 12 columns don't fit on the row.
I have also tried this on Foundation but the results are the same.
Example:
<div class="container">
<div class="row">
<div class="col-xs-1">1</div>
<div class="col-xs-1">2</div>
<div class="col-xs-1">3</div>
<div class="col-xs-1">4</div>
<div class="col-xs-1">5</div>
<div class="col-xs-1">6</div>
<div class="col-xs-1">7</div>
<div class="col-xs-1">8</div>
<div class="col-xs-1">9</div>
<div class="col-xs-1">10</div>
<div class="col-xs-1">11</div>
<div class="col-xs-1">12</div>
</div>
</div>
Or here on the file I am working on:
Edit: no loger true since I fixed it.
Is this the expected behavior? Can this be fixed, and if so what would be the best way?
That's because the space between divs. Add this CSS to your "row" div:
.no-gutter > [class*='col-xs-']{padding-right: 0; padding-left: 0}
In html:
<div class="row no-gutter">
...

how to implement responsive three columns boxed layout using bootstrap?

I am using the following to create a 3 columns layout feel to my website:
<div>
<div class="foo col-md-4">
</div>
<div class="foo col-md-4">
</div>
<div class="foo col-md-4">
</div>
<div class="foo col-md-4">
</div>
</div>
The above works great, and no matter how many foo items I added, it will format it to three columns layout automatically. However, I wanted to add a boxed feeling to each of the foo item, so that it does not look like that they're attached to each other. To achieve this, I added margin to the foo class:
.foo
{
margin: 3px 3px 3px 3px;
}
Adding the above, changes the layout become a two column layout.
My goal is to replicate responsive boxed layout, just like one we find in google plus.
Since the Bootstrap cols already having padding, you could make the content of your columns boxed.. For example, the panel creates a boxed effect.. No additional CSS required:
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">Title</div>
<div class="panel-body">Content here..</div>
</div>
</div>
Demo on Bootply: http://bootply.com/96277
Also, you may be interest in this Bootstrap Google+ project:
http://iatek.github.io/bootstrap-google-plus/
http://jsbin.com/akaQufU/3
Put a div inside the col-* this can be done.
CSS
body {background:#eee}
/* demo */
.container {padding:3%;}
/* put a div inside .foo style for demo */
.foo > div {
background:#fff;
margin-bottom:4px;
padding:2%
}
/* adjust row margins */
.row.foo-row {
margin-left: -2px;
margin-right: -2px;
}
/* adjust padding */
.row.foo-row .col-sm-4,
.row.foo-row .col-md-4,
.row.foo-row .col-lg-4 {
padding-left: 2px;
padding-right: 2px;
}
HTML
<div class="container">
<div class="row foo-row">
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
<div class="foo col-md-4">
<div>
something
</div>
</div>
</div>
</div>
how about adding inset border instead
.foo
{
border-color:transparent;
border:inset 3px;
}
because margin will be calculated as a column extra width
anyway if you want to seperate them without using borders , then just use padding
.foo
{
padding:3px 3px 3px 3px;
}
Your columns should already spaced properly by your code and bootstrap's grid system, you just need need to added a margin to the bottom to stop them touching.
margin-bottom: 3px;
The problem you had with it converting to a 2 column was because you were adding side margin of 3px as well, which throws bootstraps grid system out.
You can't use padding (well) because bootstrap uses it for spacing and that will be more pain than gain.

Resources