Foundation framework nested columns - html

super-new to grids and Foundation (I'm using 6.3). I just wanted to check I had this correct, as I was finding it difficult to check against the official documenation.
Basically Im trying to center 8 columns in a row. Then I want two columns within this, one for content and a smaller one for a sidebar.
Initially I created the following as it made sense to me that a large-8 column would then have a large-6 and large-2 within it, adding up to the 8 of the container.
<div class="row">
<div class="large-8 columns large-centered">
<div class="large-6 columns" style="background-color: red;">1</div>
<div class="large-2 columns" style="background-color: green;">2</div>
</div>
</div>
This did not work, but the following does. Before I continue I wanted to check if this is the correct way of doing what I want to do (so effectively the large-8 and large-4 add up to 12 again, despite being nested within a large-8.
<div class="row">
<div class="large-8 columns large-centered">
<div class="large-8 columns" style="background-color: red;">1</div>
<div class="large-4 columns" style="background-color: green;">2</div>
</div>
</div>

The second one will work in most scenarios, but the "Foundation" way of doing what you are asking for (from http://foundation.zurb.com/sites/docs/grid.html) is:
<div class="row">
<div class="large-8 large-offset-2 end columns">
<div class="row">
<div class="large-8 columns" style="background-color: red;">1</div>
<div class="large-4 columns" style="background-color: green;">2</div>
</div>
</div>
</div>
So you have:
2 col | 8 col | 2 col
--------------------------------------
| 8 col | 4 col |
.end simply ends a row without having to specify an empty column to fill up the space, and you need the second .row (though it kind of works without it) because you may run into nesting problems further down the line otherwise.

Related

What is best way to implement Bootstrap col-md-12 inside row? [duplicate]

This question already has answers here:
Where to place bootstrap row class
(4 answers)
Closed 4 years ago.
Let's say I have to nest three bootstrap col classes and the last one will be col-md-12 so it goes 100%. My question is, Is that ok to nest col-md-12 in one row like first example or do I need to create another row for col-md-12 ?
Eg 1
<div class="row">
<div class="col-md-6">
1
</div>
<div class="col-md-6">
2
</div>
<div class="col-md-12">
3
</div>
</div>
or
Eg 2
<div class="row">
<div class="col-md-6">
1
</div>
<div class="col-md-6">
2
</div>
</div>
<div class="row">
<div class="col-md-12">
3
</div>
</div>
It is absolutely fine to have more columns in a row than will fit in it. They will wrap.
What's more, this is essential to Bootstrap's approach to responsive design.
You might have something like:
<div class="row">
<div class="col-sm-6 col-lg-3">…</div>
<div class="col-sm-6 col-lg-3">…</div>
<div class="col-sm-6 col-lg-3">…</div>
<div class="col-sm-6 col-lg-3">…</div>
</div>
For a 4x1 layout on a large window and a 2x2 layout on a small window.
If you had to add a new .row container for each row, this would be impossible.
if you need the contents to be in the same Row then you can follow your example 1,
else you may proceed to following example 2 of your post.
Both are correct,depends on your requirement which one you want to use.
First example will put your columns inside same row but second example will create a seperate row for your col-md-12
Hope that helps

How to change order of three columns on Foundation with no issues

I'm using Foundation 6 Framework and having some issues to change the order of three columns to looks like two on Desktop.
I have this layout on mobile breakpoint:
[ column 1 ]
[ column 2 ]
[ column 3 ]
and on Desktop looks like this:
[ column 2 ][ column 1 ]
[ column 2 ][ column 1 ]
[ column 2 ][ column 3 ]
- - - - - - - ->[ column 3 ]
Desktop Layout Image example
The page doesn't always has a big content on column number 2, sometimes it breaks:
Desktop Layout with The problem
Since I can't use Flex Box yet, at first I tried to use Source Ordering (pull and push), but it doesn't works well with stacked columns (like columns 2 and 3 in this case). This solution was applied using the class float-right of Foundation on column 1 (assuming that column 2 already has 'float: right' because of being the last column).
My code:
<div class="row">
<div class="column small-12 large-4 float-right">column 1</div>
<div class="column small-12 large-8">column 2</div>
<div class="column small-12 large-4">column 3</div>
</div>
Does anyone know a good way to solve this problem? Thanks.
The situation has changed since this question was filed. Push/pull is on its way out. Now in Zurb Foundation 6+ the XY Grid and source ordering is the preferred solution and in Zurb 7 the old float grids are to be deprecated. See https://foundation.zurb.com/sites/docs/flexbox-utilities.html#source-ordering
The flexbox "order" css attribute can now be applied to individual items.
Or change the classes (eg "medium-order-1") as in the example:
<div class="grid-x grid-padding-x">
<div class="cell small-6 small-order-2 medium-order-1">
This column will come second on small, and first on medium and larger.
</div>
<div class="cell small-6 small-order-1 medium-order-2">
This column will come first on small, and second on medium and larger.
</div>
</div>
[I realize the question is in the context of being unable to use flexbox, but this is currently the correct answer for the largest audience]
Why don't you try breaking it down into one more set of rows and columns? For instance:
<div class="row">
<div class="small-12 large-8 columns">
<div class="row">
<div class="large-12 columns">column 2
</div>
</div>
</div>
<div class="small-12 large-4 columns">
<div class="row">
<div class="large-12 columns">column 1
</div>
</div>
<div class="row">
<div class="large-12 columns">column 2
</div>
</div>
</div>
</div>
By using correct order of layout and use of pull and push class. Look at this 3 column example:
<div class="row">
<div class="medium-6 medium-push-3 columns">
Page content
</div>
<div class="medium-3 medium-push-3 columns">
<h4>Course Details</h4>
<table>
<tbody>
<tr>
<td>Course Fee:</td>
<td>£ 50</td>
</tr>
<tr>
<td>Course Duration:</td>
<td>1 Month</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="medium-3 medium-pull-9 columns">
<div>
<h4>Course Map</h4>
List of courses
</div>
</div>
</div>
make sure you go through the Source Ordering part in the docs:
http://foundation.zurb.com/sites/docs/grid.html#source-ordering
you can use small-push-x, large-pull-x (replace x in numbers) to control the order of things
Founds this one with "order-1, order 2"
ref https://foundation.zurb.com/forum/posts/50758-source-ordering-issue
Example
Our priority is you
EST skip tracers act with integrity, respect, and courtesy as
it is our goal to provide service that exceeds expectations.
We go the extra mile to ensure that you are satisfied with our results.

Bootstrap Grid Offset Quetsion

I'm new to Bootstrap and I came across this issue.
<div class="container row">
<div id="page" class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div id="header"></div>
<div id="article"></div>
<div id="footer"></div>
</div>
<div class="col-lg-2 col-md-1"></div>
In boostrap documentation it shows that I dont have to use the last div.
doc: <div class="row">
<div class="col-md-6 col-md-offset-3">.col-md-6 .col-md-offset-3</div>
</div>
6 + 3 = 9. There are 3 col missing. I just want to make sure I understood this well before progressing into more details.
IF there are col missing inside a row will row automatically add them?
Or will I have some sort of a surprise bug at the long run.
I was using the 1200px grid system before. and I always had to add the the cols in correct order and correct numbers.
6+3= 9 & The remaining columns/grids i.e 3 columns space will remain empty, it won't give any bug, it just center align the DIV having class col-md-offset-3 by moving it 3 columns from left and 3 columns on right are empty so the DIV will be center aligned.
Hope this will bring some clarity, thanks.
First: Don't put class container and row in the same div.
Answer: If you start a new row it will start counting from zero again.
You could put all your sections in separate containers.
<div class='container'><!--this is your container-->
<div class='row'><!--this is your row-->
<div class='col-md-4 col-md-offset-3'><!--populating row with col with offset-->
</div>
</div>
<div class='row'>
<!--some other cols will start counting from zero because it is a new row-->
</div>
</div>

Bootstrap grid system: pull last column right regardless of other columns?

I have the following simplified markup:
<div class="row">
<div class="col-lg-3" ng-if="isSuperUser()">
Conditional column 1
</div>
<div class="col-lg-3">
Column 2
</div>
<div class="col-lg-6">
Column 3
</div>
</div>
I want Column 3 to take up the last 6 grid columns always. I also want the contents of Column 1 or Column 2 if not a super user to take up the first 3 grid columns depending.
The problem is when the Column 1 is not displayed, Column 2 and Column 3 shift to the left such that Column 3 is no longer on the right side. A solution that seems hacky is to add a <div class="col-lg-3" ng-if="!isSuperUser()"> before Column 3, but it seems like there may be a better solution.
I can't see anything in Bootstrap's documentation that demonstrates this functionality. I see there is push and pull classes, but they don't seem to be what I'm looking for.
Thanks in advance.
JSBIN
you can try nest row into the .col-xs-*. That's mean you could use the out row to fixed position before you want hidden something.
<div class="container">
<div class="row">
<div class="col-xs-6">col 6
<div class="row">
<div class="col-xs-2">
2
</div>
<div class="col-xs-10">
10
</div>
</div>
</div>
<div class="col-xs-6">col 6
<div class="row">
<div class="col-xs-12">
your purpose
</div>
</div>
</div>
</div>
</div>
You are looking to offset columns in Bootstrap. Conditionally add the class .col-lg-offset-3 to the second column.

twitter bootstrap fluid grid columns [duplicate]

This question already has answers here:
Changing number of columns dynamically in Bootstrap grids
(2 answers)
Closed 9 years ago.
When using Bootstrap's fluid grid, is it necessary to declare a column when you want the content to span the entire width of the row. In other words, is this sufficient
<div class="row-fluid">
This column should span the full width of the row
</div>
Or is it really necessary to do this (as the docs suggest):
<div class="row-fluid">
<div class="span12">This column should span the full width of the row</div>
</div>
Also, when I want to nest columns in a fluid grid, according to the docs
Nesting with fluid grids is a bit different [to a non-fluid grid]: the number of nested columns should not match the parent's number of columns. Instead, each level of nested columns are reset because each row takes up 100% of the parent column.
The docs then go on to give this example where the first row is one full-width column and the second row has 2 half-width columns
<div class="row-fluid">
<div class="span12">Fluid 12
<div class="row-fluid">
<div class="span6">Fluid 6</div>
<div class="span6">Fluid 6</div>
</div>
</div>
</div>
Apart from the class name of the rows, I don't see how this is at all different to a non-fluid grid. Also, this example seems to contradict the statement
the number of nested columns should not match the parent's number of columns
Because last time I checked 6 + 6 = 12. Can someone improve on this explanation?
(1) I don't see how this is at all different to a non-fluid grid
It uses percentages
(2) the number of nested columns should not match the parent's number of columns
Well, bad example, what they simply mean is that the number in the class names should always add up to 12, regardless of what they are nested in.
This is correct:
<div class="row-fluid">
<div class="span6 row-fluid">
<div class="span4"> </div>
<div class="span4"> </div>
<div class="span4"> </div>
</div>
</div>
instead of this, which is wrong:
<div class="row-fluid">
<div class="span6 row-fluid">
<div class="span2"> </div>
<div class="span2"> </div>
<div class="span2"> </div>
</div>
</div>