I'm having issues with the following markup. The columns from the last row do not fill up the whole width even though the container is fluid and the sum of their classes is 12.
<div class="container-fluid">
<div class="row" id="header">
<h1>Title</h1>
</div>
<div class="row" id="ndHeader">
<h2>Categories </h2>
</div>
<div class="row">
<div class="col-xs-6 col-sm-3" id="sidebar">.col-xs-6 .col-sm-3</div>
<div class="col-xs-6 col-sm-9">
<div class="clearfix hidden-sm-up"></div>
<div class="row tileRow">
<div class="col-xs-4 col-sm-3 tile">
<div class="tileContent"> asd </div>
</div>
<div class="col-xs-4 col-sm-3 tile">
asd asd asdasdasdaddddddddddddddddddddddddddddddddddddddddddddddddddd
</div>
<div class="col-xs-4 col-sm-3 tile">
asd asd asdasdasdaddddddddddddddddddddddddddddddddddddddddddddddddddd
</div>
</div>
</div>
</div>
</div>
You can see the live example : http://www.bootply.com/GsJbodLFwb#
The columns are using the correct width. In the last row you have two main divs, a col-sm-3 and a col-sm-9. The col-sm-9 is correctly using up 75% of the available space. The div that has the col-sm-3 attached to it has some css overwriting its width. You need to remove the following code to get that back to spanning the full 25% that it should be:
#sidebar {
background-color:green;
//width:15em; <-- remove this
height:100%;
}
Also, the three divs inside of your tile row only add up to 9 at the sm size. You'll want to change those to col-sm-4 or just remove them altogether as the col-xs-4 will do the same thing.
You are setting widths for these 2 cells
<div class="col-xs-6 col-sm-3" id="sidebar">...</div>
<div class="col-xs-6 col-sm-3">...</div>
First one has a width: 15em; and the second one is width: 75%; which is causing that row width to behave oddly. If you need a custom width table i suggest not using the bootstrap rows & cells and just make your own.
<div class="row">
<div class="col-xs-12 col-sm-12">
*my custom table or divs here*
</div>
</div>
Related
Consider this case
<div class="row">
<div class="col-md-3 col-sm-3 col-xs-3"></div>
<div class="col-md-6 col-sm-6 col-xs-6"></div>
<div class="col-md-3 col-sm-3 col-xs-3"></div>
</div>
In this case, suppose if I need to fill the first div (first column) within the parent div with a background of #FF0000 how can I do it? If I can do it in a regular way, that is by specifying the style="background-color:red", the background changes only for the content written within it. Not if I create another div inside it and set its height and width to 100% nothing happens. Why is it so? And how can I do it the correct way?
Use a
<div class="col-md-3 col-sm-3 col-xs-3"> </div>
And set the background color as you wish.
Simple and elegant.
Empty div has no height. Use height, min-height, padding-top or padding-bottom to make empty div visible. You may do it
by class for column
by class for row with :first-child
Bootstrap uses col-xs- for screens of any width if there are no other conditions. Therefore col-md-3 col-sm-3 col-xs-3 is equivalent to col-xs-3.
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.make-first-div-red > div:first-child,
.make-it-red {
background-color: #f00;
min-height: 30px;
margin-bottom: 10px;
)
<div class="row make-first-div-red">
<div class="col-xs-3"></div>
<div class="col-xs-6"></div>
<div class="col-xs-3"></div>
</div>
<div class="row">
<div class="col-xs-3 make-it-red"></div>
<div class="col-xs-6"></div>
<div class="col-xs-3"></div>
</div>
<div class="row">
<div class="bg col-md-3 col-sm-3 col-xs-3">adadadadada</div>
<div class="col-md-6 col-sm-6 col-xs-6"></div>
<div class="col-md-3 col-sm-3 col-xs-3"></div>
</div>
and use this css
.bg{background:#FF0000}
and it will work
What I am trying to do is to have two columns of 3 nested pink squares each, at the large and med settings, then on small screen tablet a single column with 3 pink squares then another single column with 3 pink squares under that. Then at the xs mobile level I'm trying to again have two columns but with 1 column of nested pink squares in each. I thought this is what my css is requesting, but that's not what is happening :( What am I doing wrong here?
Here's a plunker
Here's the html:
<div class="container">
<div class="row">
<div class="col-xs-6 col-sm-12 col-md-6 col-lg-6"><h4>My Subtitle</h4>
<div ng-repeat="x in things">
<div class="col-xs-6 col-sm-4 col-md-4">
<div class="cube">
<b>{{x.title}}</b> </br> {{x.content}}
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-12 col-md-6 col-lg-6"><h4>My Subtitle 2</h4>
<div ng-repeat="x in things2">
<div class="col-xs-6 col-sm-4 col-md-4">
<div class="cube">
<b>{{x.title}}</b> </br> {{x.content}}
</div>
</div>
</div>
</div>
</div>
It seems like you're confused by the number at the end of the class.
While nesting .col-xs-6 inside another .col-xs-6, you will get a column which takes only 50% of the width.
It's a primary principle of 12 column grid. Divide 100% / 12 = 8.33333333333% and you will get width property of a single column in percents, please have in mind that the width in percents is calculated according to the parent width.
Bootstrap's grid is not informative while nesting.
Eg. think of .col-xs-6 as width: 50%;, .col-xs-4 is width: 33.33333%;
halfzebra is right. If you you nest columns you always have new 12 columns inside another one.
<div class="col-md-6">
<div class="row">
<div class="col-md-12">
This will fill col-md-6
</div>
</div>
</div>
And like in example above I always like to use rows when Im starting one.
I don't know if I got you right but you could do something like this:
<div class="container">
<div class="row">
<div class="col-xs-6 col-sm-12 col-md-6 col-lg-6">
<div class="row">
<div class="col-md-12">
<h4>My Subtitle</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-4" ng-repeat="x in things">
<div class="cube">
<b>{{x.title}}</b> </br> {{x.content}}
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-12 col-md-6 col-lg-6">
<div class="row">
<div class="col-md-12">
<h4>My Subtitle 2</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-4" ng-repeat="x in things2">
<div class="cube">
<b>{{x.title}}</b> </br> {{x.content}}
</div>
</div>
</div>
</div>
</div>
</div>
Keep in mind that your red boxes are not always fitting in to the columns. I changed width to 100% so you can see how columns are acting.
Plunker: http://plnkr.co/edit/EE4eWrrGIJ0lFdPBcq7T?p=preview
I'd like to create a 4 column footer that looks nice. The content for the footers varies in width and I would like to have an equal amount of space between each block of text in the columns. The only way I know to do this is to add a class to each div and play with the margins until things look right. I seem to have to add a negative margin to one or more columns so that the spacing is equal between each block of text. I can get things to look good on large screens, but then when you view the page in a smaller screen, divs overlap and things get wonky. I'd like the columns to start stacking on top of each other and filling up the entire width of the screen as much as possible. Here's a jsfiddle and my code that shows what I'm trying to do. What would you add to this to make it look good on desktops and as many mobile devices as possible?
http://jsfiddle.net/natetg/qhtyL7t8/
'<div class="navbar navbar-fixed-bottom footer">
<div class="container">
<div class="row">
<div class="col-xs-6 col-md-4 col-lg-3">
<p>columnContentWithLargeWidth</p>
</div>
<div class="col-xs-6 col-md-4 col-lg-3">
<p>columnContentShort</p>
</div>
<div class="col-xs-6 col-md-4 col-lg-3">
<p>columnShort</p>
</div>
<div class="col-xs-6 col-md-4 col-lg-3">
<p>ColumnContentWithLargestWidthAndWantThisAllOnOneLinePlease</p>
</div>
</div>
</div>
</div>`
Try using .container-fluid and .row-fluid instead of container and row.
<div class="navbar navbar-fixed-bottom footer">
<div class="container-fluid">
<div class="row-fluid">
<div class="col-xs-6 col-md-4 col-lg-3">
<p>columnContentWithLargeWidth</p>
</div>
<div class="col-xs-6 col-md-4 col-lg-3">
<p>columnContentShort</p>
</div>
<div class="col-xs-6 col-md-4 col-lg-3">
<p>columnShort</p>
</div>
<div class="col-xs-6 col-md-4 col-lg-3">
<p>ColumnContentWithLargestWidthAndWantThisAllOnOneLinePlease</p>
</div>
</div>
</div>
</div>
I was creating a template today using bootstrap. suddenly My grids are not getting any margin between them.
my markup are pretty simple:
<div class="container" div style="margin-top:50px;margin-bottom:50px">
<div class="row">
<div class="col-lg-3 col-md-3 col-xs-3 col-sm-3 box">
<p>flacon</p>
</div>
<div class="col-lg-3 col-md-3 col-xs-3 col-sm-3 box">
<p>flacon</p>
</div>
<div class="col-lg-3 col-md-3 col-xs-3 col-sm-3 box">
<p>flacon</p>
</div>
<div class="col-lg-3 col-md-3 col-xs-3 col-sm-3 box">
<p>flacon</p>
</div>
</div>
</div>
I didn't face anything like it before. please help me.
There is no margins between the columns in bootstrap but there is padding. When you set the background-color to white, that creates a background for the padding too which is why it looks continuous and not separated.
Add this:
<div class="col-sm-3">
<div class="white-box">
...
</div>
</div>
With .white-box whatever you want such as background-color: white;
The Bootstrap grid-system does not add any margins - instead it adds a padding inside the columns. You could build something like this:
<div class="container" div style="margin-top:50px;margin-bottom:50px">
<div class="row">
<div class="col-xs-3">
<div class="col-xs-12 box">
<p>flacon</p>
</div>
</div>
<div class="col-xs-3">
<div class="col-xs-12 box">
<p>flacon</p>
</div>
</div>
<div class="col-xs-3">
<div class="col-xs-12 box">
<p>flacon</p>
</div>
</div>
<div class="col-xs-3">
<div class="col-xs-12 box">
<p>flacon</p>
</div>
</div>
</div>
</div>
I also removed your many col-XX-3 classes as stated in my comment. For mor details see Bootstrap documentation
Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller devices. Therefore, applying any .col-md- class to an element will not only affect its styling on medium devices but also on large devices if a .col-lg- class is not present.
In bootstrap, I need to keep the proportion of the following columns, yet I need to group 2 columns with a div so that I can modify the background.
<div class="col-xs-6 col-md-3"></div>
<div class="col-xs-6 col-md-3"></div>
<div class="col-xs-6 col-md-6"></div>
I am trying to do something like:
<div class="col-xs-6 col-md-3"></div>
<div class="grey">
<div class="col-xs-6 col-md-3"></div>
<div class="col-xs-6 col-md-6"></div>
</div>
But it changes the proportion, as it is considering grey div as 18 grid.
col-*-4 will give you 3 columns of equal width (spanning 4 cols each). No need to group them to modify their background color. Just apply the same class with background color defined in your css:
<div class="col-xs-4">Col 1</div>
<div class="col-xs-4 grey">Col 2</div>
<div class="col-xs-4 grey">Col 3</div>
css
.grey{backround:grey;}
Demo: http://www.bootply.com/E78M9vm9Uk
My personal advise will be this. Though I'm really certain of what your goal is. Since bootstrap has an 12 wide grid your col-xs-6 will put 2 columns beside each other and the next one below.
<div class="col-xs-6 col-md-3"></div>
<div class="col-xs-6 col-md-3 grey"></div>
<div class="col-xs-6 col-md-6 grey"></div>
If you really looking for grouping I should consider this approach:
<div class="col-xs-6 col-md-3"></div>
<div class="grey col-md-9">
<div class="col-xs-6 col-md-4"></div>
<div class="col-xs-6 col-md-8"></div>
</div>
But that will not correspond when he enters xs. Since it is not clear to me what you want with that size.