How to setup nested grid with Skeleton - skeleton-css-boilerplate

I want to add a grid of images and content in the main content area of my website page.
I have a basic two column template, and I want to place the grid in the large content area. Everything works fine, but as soon as I resize to portrait I loose all my margins between divs. I am not too sure what is the proper way to group these items in skeleton. Do i need to end my container for each row? Any help or suggestions is greatly appreciated.
<div class="container">
<div class="four columns"></div>
<div class="twelve columns">
<!-- grid goes here -->
<div class="container">
<div class="six columns alpha"></div>
<div class="six columns omega"></div>
<div class="six columns alpha"></div>
<div class="six columns omega"></div>
</div>
</div><!-- end twelve columns>
</div><!-- end container -->

I see no one's answered this before. I assume you've already solved this, so this answer is for anyone else trying to find
The issue is that the container class has a fixed width of 960 pixels, so you can't nest them. The second problem is that the columns inside (that you're trying to nest) exceed the column count. See the 'clearfix' class. Offhand, this was the cleanest solution I found:
<div class="container">
<div class="four columns">four columns</div>
<div class="twelve columns">
<div class="sixteen columns clearfix">
<div class="three columns alpha"> first</div>
<div class="three columns">second</div>
<div class="three columns">third</div>
<div class="three columns omega">fourth</div>
</div><!-- end clearfix -->
</div><!-- end twelve columns>
</div><!-- end container -->

The part that I missed the first time I saw this answer was that the columns in between Alpha and Omega are just labeled three columns. So for the first column use alpha and the last column use omega. The initial question doesn't work because they have two alpha and omegas. If you look at the css alpha and omega just give them 0px margins on either left(alpha) or right(omega).

Related

Why is my bootstrap v3 column not 100% wide on my mobile phone?

I've read a lot about bootstraps breakpoints and grid system now and perused many stackoverflow questions but remain bamboozled.
I have a simple bootstrap v3 container like this:
<div class="container">
<div class="row col-md vertical-align">
<div class="col-md-5">
image
</div>
<div class="col-md-7 d-flex">
text
</div>
</div>
</div>
And in a web browser this renders beautifully, but on my phone the image and text continue to occupy one row with no break and the image is thus scaled tiny and ugly and I'd like Bootstrap to do what it does best, render that image at the full phone width and the next beneath it, that is, break these two columns.
A live sample is her, at present:
http://hobart.gamessociety.info/
and I would be most grateful if anyone with experience could lend some insight into why this doesn't render as I'd like on my phone.
As I understood bootstrap it's phone first, and md says apply the 5/7 split on medium and larger screens and on smaller ones do what it does sensibly, i.e. not scale that image to tiny proportions and show both columns side by side, but break between them and show one above the other.
The class "vertical-align" adds the css style "display:flex" if you remove that you will see the items behaving as you currently desire (I think). Use chrome and inspect to add/remove css styles.
You could just add col-xs-12 to each div class.
<div class="container">
<div class="row col-md vertical-align">
<div class="col-md-5 col-xs-12">
image
</div>
<div class="col-md-7 col-xs-12 d-flex">
text
</div>
</div>
</div>
Here is an alternative to your second question
create a css class
.myClass {
float:none;
display:inline-block;
vertical-align:middle;
margin-right:-4px;
}
And add it to the inner divs
<div class="container">
<div class="row">
<div class="col-md-5 myClass">
image
</div>
<div class="col-md-7 myClass">
text
</div>
</div>
</div>
Found the answer here Twitter Bootstrap 3, vertically center content

bootstrap 3 grid issue - small columns overriding medium or larger

I’m having an issue with the bootstrap grid. I’m trying to create (3) four column divs on medium screens, on small screens I’m trying to create six column divs that are offset 3 columns so they are centered. and on extra small screens twelve columns. Seems like something I’ve done a million times… but on medium or larger they are stacking using the .sm class… not sure what’s happening?
<div class="row">
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-4">col-xs-12 col-sm-6 col-sm-offset-3 col-md-4</div><!-- close col -->
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-4">col-xs-12 col-sm-6 col-sm-offset-3 col-md-4</div><!-- close col -->
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-4">col-xs-12 col-sm-6 col-sm-offset-3 col-md-4</div><!-- close col -->
</div><!-- close row -->
here is a codepen: https://codepen.io/aaron4osu/pen/Powpezo
Your post is a bit confusing, but I'll try to help.
Your first issue is using .col-offset- improperly which is preventing your columns from operating correctly (read more about offsetting here: https://getbootstrap.com/docs/3.4/css/#grid-offsetting)
Your second issue is using .col-sm-6 three times.
With the Bootstrap grid system, your column classes must always equal 12 (because it's a 12 column grid). Having .col-sm-6 three times equals 18 (not 12) so Bootstrap will push your 3rd .col-sm-6 column underneath the others.
Also, always wrap a .container or .container-fluid around your .row or you're going to run into problems later like horizontal scrolling.
And finally, to center your divs on sm and xs, just use .col-xs-12 and then your divs will be centered (and 100% width) until they reach the .col-md- breakpoint, and then they will be .col-md-4 (3 columns, because 4 goes into 12 three times):
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-4">Column 1</div>
<div class="col-xs-12 col-md-4">Column 2</div>
<div class="col-xs-12 col-md-4">Column 3</div>
</div>
</div>

Boostrap - Pull col-md-3 above col-md-6 at first breakpoint

I have two columns:
<div class="col-md-9">
...main content here
</div>
<div class="col-md-3">
...sidebar content here
</div>
I want the col-md-3 on the right side until the first breakpoint then on top thereafter at smaller viewports. I played around with pushing and pulling columns, but couldn't figure out how to display correctly. Please advise.
This should do it. Demo
The idea is that the top div will always break above. Since we want the top div in the right position we push it to the right by the offset of the other column which is 9. Then we pull the bottom div back 3 columns to put it in the left position.
<div class="col-md-3 col-md-push-9">
...sidebar content here
</div>
<div class="col-md-9 col-md-pull-3">
...main content here
</div>

If more than 12 columns wrap onto a new line automatically, do we really need to close it?

I've been using Bootstrap for a while (specifically, version 3) and have noticed that I still am unsure whether I should always close columns with a that has a class of .row assigned to it after every 12 columns OR can I wait and apply that closing .row at the end of my code as long as I understand that any columns that add up to more than 12 columns in a single row will simply wrap automatically onto a new line. The benefit of the latter option is that it would be less code and less chances of forgetting to add that closing div tag for each 12 column row.
In other words, is it better to do this?
<div class="row">
<div class="col-md-8">
<p>some content here</p>
</div>
<div class="col-md-4">
<p>some content here too</p>
</div>
</div><!--/.row-->
<div class="row">
<div class="col-md-6">
<p>some content here</p>
</div>
<div class="col-md-6">
<p>some content here too</p>
</div>
</div><!--/.row-->
OR, is this method more efficient?
<div class="row">
<div class="col-md-8">
<p>some content here</p>
</div><!--/.col-md-8-->
<div class="col-md-4">
<p>some more content here</p>
</div><!--/.col-md-4-->
<div class="col-md-6">
<p>some content here</p>
</div>
<div class="col-md-6">
<p>some content here too</p>
</div>
</div><!--/one .row div to close them all-->
...well, it actually depends on the design - I am using both depending on the circumstance.
The difference lies in the height of the elements. If the two cols in the first row had different heights, closing the row would essentially mean that the two bottom columns would be aligned starting from the same top position.
However if the cols have different heights NOT closing the row can have different results.
edit: ...this is because of the way float works on the cols elements. Closing a row clears the float.
edit2: here is an example of both cases:
not closing row:
<div class="row">
<div class="col-">
content
</div>
<div class="col-">
content
</div>
<div class="col-">
content
</div>
<div class="col-">
content
</div>
</div>
http://jsfiddle.net/b2rkgd5w/1/
closing row:
http://jsfiddle.net/1krj49pm/2/
besides closing the row element the rest of the code is exactly the same.

Bootstrap 3: Offset isn't working?

I have this code:
<div class="row">
<div class="col-sm-3 col-sm-offset-6 col-md-12 col-md-offset-0"></div>
<div class="col-sm-3 col-md-12"></div>
</div>
What I want for small (sm) screens is to have two divs that have three columns each, and an offset of 6 columns for the first div.
For medium (md) screens, I would like to have two divs with twelve columns each (one horizontally stacked under the other), with no offsets.
Somehow the browser doesn't recognize the class col-md-offset-0. It still uses the col-sm-offset-6 class. Any ideas why?
Which version of bootstrap are you using? The early versions of Bootstrap 3 (3.0, 3.0.1) didn't work with this functionality.
col-md-offset-0 should be working as seen in this bootstrap example found here (http://getbootstrap.com/css/#grid-responsive-resets):
<div class="row">
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
<div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0">.col-sm-5 .col-sm-offset-2 .col-md-6 .col-md-offset-0</div>
</div>
There is no col-??-offset-0. All "rows" assume there is no offset unless it has been specified. I think you are wanting 3 rows on a small screen and 1 row on a medium screen.
To get the result I believe you are looking for try this:
<div class="container">
<div class="row">
<div class="col-sm-4 col-md-12">
<p>On small screen there are 3 rows, and on a medium screen 1 row</p>
</div>
<div class="col-sm-4 col-md-12">
<p>On small screen there are 3 rows, and on a medium screen 1 row</p>
</div>
<div class="col-sm-4 col-md-12">
<p>On small screen there are 3 rows, and on a medium screen 1 row</p>
</div>
</div>
</div>
Keep in mind you will only see a difference on a small tablet with what you described. Medium, large, and extra small screens the columns are spanning 12.
Hope this helps.
If I get you right, you want something that seems to be the opposite of what is desired normally: you want a horizontal layout for small screens and vertically stacked elements on large screens. You may achieve this in a way like this:
<div class="container">
<div class="row">
<div class="hidden-md hidden-lg col-xs-3 col-xs-offset-6">a</div>
<div class="hidden-md hidden-lg col-xs-3">b</div>
</div>
<div class="row">
<div class="hidden-xs hidden-sm">c</div>
</div>
</div>
On small screens, i.e. xs and sm, this generates one row with two columns with an offset of 6. On larger screens, i.e. md and lg, it generates two vertically stacked elements in full width (12 columns).