Bootstrap 3: breaking a two-column row into two one-column rows when on mobile - twitter-bootstrap-3

I currently have:
<div class="row">
<div class="col-xs-4" id="LocationWrapper">
<div class="FullWidth HorizontallyCentered">Select the location:</div>
<select id="ddlLocation"></select>
<span id="LocationNote">blablabla</span>
</div>
<div class="col-xs-8" id="GraphsOptionsWrapper">
<div class="FullWidth HorizontallyCentered">Select the graph:</div>
</div>
</div>
This works fine for desktop. However, on mobile the columns are just too small to hold what is needed. In this case, it would be better to have two rows (instead of two columns in one row), with one column in each row.
How could I do it without duplicating the content? The content has some controls like select that should be unique on the page.
Thank you!

I hope this structure will help you.
<div class="row">
<div class="col-sm-4" id="LocationWrapper">
<div class="FullWidth HorizontallyCentered">Select the location:</div>
<select id="ddlLocation"></select>
<span id="LocationNote">blablabla</span>
</div>
<div class="col-sm-8" id="GraphsOptionsWrapper">
<div class="FullWidth HorizontallyCentered">Select the graph:</div>
</div>
</div>

Related

How to align a button right in Materialize card-action

I am using Materialize, and I need to align a button to the right side of the card in the card-action.
This is the code:
<div class="card-action">
This is a link
</div>
This is the result:
If I remove the class="right" then I get this result:
I want the result from the second image, except the button should be aligned to the right. Am I missing something about the materialize card-action? How should I get this behavior?
It should be right-align instead of right and you've to use it on card-action div. You can check about the alignment classes in Helper page of the documentation.
<div class="row">
<div class="col s12 m4">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title">Card Title</span>
<p>I am a very simple card. I am good at containing small bits of information. I am convenient because I
require little markup to use effectively.</p>
</div>
<div class="card-action right-align">
<a class="btn blue" href="#">Right</a>
</div>
</div>
</div>
</div>
You Just Need to Mention the Alignement in below way
<div class="card-action right-align">
YOUR CONTENT WILL ALIGHT TO RIGHT
</div>

Twitter Bootstrap 3 SideBar Notification not displaying properly

I am creating a web page whereby I want content to display at the left side(9 columns) and Ads to display at the right sidebar(3 columns) .At the left side I have nested two rows and want content t0 be displayed inside the rows. But when I test on a live server the Ads dont display properly. I am using Bootstrap 3 to partition the page.
<!--Parent row -->
<div class="row">
<div class='row'>
<div class="col-sm-9">
//Page content.....
</div>
</div>
<div class='row'>
<div class="col-sm-9">
//Page content.....
</div>
</div>
<div class="row">
<div class="col-sm-9">
//...Google Ads display
</div>
</div>
</div> <!--END parent row -->
With Bootstrap, all the columns must add up to 12. I can see that you've got 3 sets of 9 columns which makes 18.
The layout would need to be as so:
<!--Parent row -->
<div class="row">
<div class="col-sm-9">
<div class="col-sm-6"><!-- Nested col 1 (of 50%) --></div>
<div class="col-sm-6"><!-- Nested col 2 (of 50%) --></div>
</div>
<div class="col-sm-3"><!-- ...Google Ads display --></div>
</div> <!--END parent row -->
This will put the Google Ads column to the right, and have two nested columns inside the Page content columns.
The .row class should be used only once per row, not per column.

bootstrap 3 grid not side by side but below

I have a forum that i found the code for online and i am customizing it. I'm using bootstrap 3, and inside the forum i want to have an 8 x 4 grid. I followed a tutorial but instead of placing it side by side the two divs are top and bottom
<div class="row">
<div class="col-md-8">
<div class="firstPost"
<div class="postHeading">
<h3>My shot, Banff Pano</h3>
</div>
<div class="postBody">
<p>
Here is a shot of Banff Alberta, Canada.
I took a series of photographs in the portrait orientation
and, using Lightroom and Photoshop, I stitched them together and
adjusted the image to bring out more contrast and colors. The settings
are f/11 at 1/500s; ISO 280.
</p>
<p>
I'm wondering if I should have used a wider aperture and
let the background be a little more blurred
</p>
</div>
<div class="postImage">
<img src="assets/banff.jpg" />
</div>
<div class="postFooter">
<p>
Posted on 7/23/15 at 12:05PM
</p>
</div>
</div>
</div> <!-- end of 8 -->
<div class="col-md-4">
<p>Something goes here</p>
</div>
</div> <!-- end of row -->
your are missing a closing tag > here
<div class="firstPost"
should be
<div class="firstPost">

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.

Organising a 3-column to 2-column in Twitter Bootstrap 3

So this totally works (goes from 4 columns to 2 on small screens):
<div class="row">
<div class="col-lg-3 col-sm-6"> 1</div>
<div class="col-lg-3 col-sm-6"> 2</div>
<div class="col-lg-3 col-sm-6"> 3</div>
<div class="col-lg-3 col-sm-6"> 4</div>
</div>
As does my 3-column, however the middle column gets stacked on top of the third one (which by then is the right/2nd column).
<div class="row" id="footer">
<div class="col-lg-3 col-sm-6">
1
</div>
<div class="col-lg-3 col-sm-6">
2
</div>
<div class="col-lg-6 col-sm-6">
3
</div>
</div>
How can I tell the middle column to stack above or underneath the first column? col-sm-pull-6 doesn't work for example.
Desired result:
1 - 3
2 - ..
The problem with switching 2 and 3 and then using push and pull, is that the 2nd column still goes a top of the 3rd column. And I need them to be like in my desired result 'diagram'.
Edit: What I can do is give the first column col-sm-12. This will push the other 2 down. That way the order is good, and since it's for a footer, the fact that the paragraph column is at the complete bottom, isn't bad either. But I'm still open for better suggestions.
The grid now looks like this:
1
2 - 3
Be sure to watch out for divs that have different heights. Those will cause things to not wrap all the way to the left like you might expect.
You can address this using the bootstrap clearfix (even conditionally) with something like:
<div class="clearfix visible-sm"></div>
Put that after a div where you'd want to start a new row at the -sm size. Repeat as needed.
So here goes,
first of all you should use the designs for smaller screens BEFORE larger screens like so:
<div class="col-sm-6 col-lg-3"> (...)
Now for your design to happen you need to to this:
<div class="col-sm-6 col-lg-3">
1
</div>
<div class="col-sm-6 col-lg-3 col-lg-push-3">
3
</div>
<div class="col-sm-6 col-lg-3 col-lg-pull-3">
2
</div>
...what I did is that I reversed the 2nd with 3rd column so that they fit my needs for the smaller screen and then by using push and pull I adjusted for the larger screens.
edit: here is a working fiddle:
http://jsfiddle.net/ujrwyrbr/2/