How to change width when columns collapse with zurb foundation template - css

I'm using zurb foundation this template.
This is a 3 columns template, and the columns collapse when window width become around under 1000 pixel.
But I don't want to make them collapse until 700 pixel. How can I change it?
In rails environment, I changed like this, but nothing seems to happen.
// foundation_and_overrides.scss
- // $row-width: rem-calc(1000);
+ $row-width: rem-calc(700);
If possible I want to delete [ad] column when the width is under 1000 px and collapse when under 700 px. If the implementation is not difficult, I'd prefer this behavior.

It looks like you're experiencing two issues here.
First, the template you reference uses the medium grid class. When the screen size hits the medium breakpoint they made the columns go full width. Here's how the rows are setup in that template:
<div class="row">
<div class="large-3 columns">
<!-- Content Here -->
</div>
<div class="large-6 columns">
<!-- Content Here -->
</div>
<div class="large-3 columns">
<!-- Content Here -->
</div>
</div>
To change this so the columns stay fixed until around 700px you could change the column classes to:
<div class="row">
<div class="medium-3 columns">
<!-- Content Here -->
</div>
<div class="medium-6 columns">
<!-- Content Here -->
</div>
<div class="medium-3 columns">
<!-- Content Here -->
</div>
</div>
The second issue is the media-query breakpoints. By default, the $small-range size is 0-40em. Depending on what you've set your $rem-base to you may need to change the ranges appropriately.
For example, if your $rem-base is the default 16px this means your grid collapses to a single column (using the HTML above) at 16px * 40 = 640px.
If you want it to collapse at exactly 700px, and your $base-rem is 16px you would need to change $small-range to (0em, 43.5em).

Related

Bootstrap 5 - several columns with normal width but one that takes up the rest of the space

If I have a scenario using Bootstrap 5 like...
<div class="container">
<div class="row row-cols-auto">
<div class="col">One</div>
<div class="col">Two</div>
<div class="col">Three</div>
</div>
</div>
All columns currently take whatever width their content needs.
I want column two to be as wide as it can be without interfering with the display of columns one and two.
Is this possible with Bootstrap alone or would I need to rely on additional CSS styling?
Just found the answer. Make all columns EXCEPT the one I want to take up all the space col-auto. Make that one class="col".
<div class="container">
<div class="row">
<div class="col-auto">One</div>
<div class="col">Two</div>
<div class="col-auto">Three</div>
</div>
</div>

Bootstrap Ordering Elements by Screen Size

Am I losing my mind, because I'm absolutely sure this code should work... but it doesn't.
I'm trying to order my elements according to screen size ie. if small screen or less, menu element is first - and if medium screen or more - menu element is second.
<div class="col-md-9 order-sm-2 order-md-1">
Main content
</div>
<div class="col-md-3 order-sm-1 order-md-2">
Menu column
</div>
What I'm getting for both small and medium screen size is: Main content (1st) and Menu column (2nd).
Can anyone help?
I suspect your problem is either that order-sm-2 and order-sm-1 should define the xs instead of sm versions,
or that the shown code isn't surrounded by the same row & container DIVs
I'm such a div (no pun intended):
<div class="col-md-9 order-2 order-md-1">
Main content
</div>
<div class="col-md-3 order-1 order-md-2">
Menu column
</div>
Needed to have a base order before introducing a breakpoint.

CSS Flexbox Responsive Layout and % widths

Using angular/flex-layout, I have a simple two-column layout.
<div fxFlex fxLayout="row">
<div fxFlex="35%">
<!-- Left Column -->
</div>
<div fxFlex="65%">
<!-- Right Column -->
</div>
</div>
On small displays I want the columns to wrap, right below left.
Using angular/flex-layout's Responsive API, I add a breakpoint for small screens (between 600px and 959px) with fxLayout.sm="column" on the container element:
<div fxFlex fxLayout="row" fxLayout.sm="column">
<div fxFlex="35%">
<!-- Left Column, Top Row -->
</div>
<div fxFlex="65%">
<!-- Right Column, Bottom Row -->
</div>
</div>
On small screens the Left Column becomes the Top Row, and Right Column, the Bottom Row.
However, fxFlex="35%" and fxFlex="65%" attributes are still honored, and so the rows overlap. The Top Row occupies 35% of the display height, since it previously occupied 35% of the display width.
Please see this Plunker for an example of the problem. Note, I used the fxLayout.xs breakpoint rather than fxLayout.sm to demonstrate the problem since Plunker's divides the display up into small sections.
I can fix this by explicitly removing fxFlex using the Responsive API (i.e. fxFlex=""):
<div fxFlex fxLayout="row" fxLayout.sm="column">
<div fxFlex="35%" fxFlex.sm="">
<!-- Left Column, Top Row -->
</div>
<div fxFlex="65%" fxFlex.sm="">
<!-- Right Column, Bottom Row -->
</div>
</div>
Please this Plunker for an example of the solution.
There are two problems with this. Firstly, it feels very, very hacky. Secondly, assuming I want the same behaviour for small and extra small displays, I end up with:
<div fxFlex fxLayout="row" fxLayout.sm="column" fxLayout.xs="column">
<div fxFlex="35%" fxFlex.sm="" fxFlex.xs="">
<!-- Left Column, Top Row -->
</div>
<div fxFlex="65%" fxFlex.sm="" fxFlex.xs="">
<!-- Right Column, Bottom Row -->
</div>
</div>
Unless there's any easier way to use the Responsive API for displays below a certain dimension, rather than set breakpoints explicitly?
The angular-flex-layout Responsive API also has a gt-sm (greater than small) property.
To avoid having to add every screen size with an fxFlex="" value you can just do something like this:
<div fxFlex fxLayout="row" fxLayout.sm="column" fxLayout.xs="column">
<div fxFlex.gt-sm="35%">
<!-- Left Column, Top Row -->
</div>
<div fxFlex.gt-sm="65%">
<!-- Right Column, Bottom Row -->
</div>
</div>
Or you can use the lt-lg (less than large) property and have
<div fxFlex fxLayout="row" fxLayout.sm="column" fxLayout.xs="column">
<div fxFlex="35%" fxFlex.lt-lg="">
<!-- Left Column, Top Row -->
</div>
<div fxFlex="65%" fxFlex.lt-lg="">
<!-- Right Column, Bottom Row -->
</div>
</div>

Bootstrap Columns: Switch Order for Mobile?

I've got a two column page:
<div class="col-md-5">
...
</div>
<div class="col-md-7">
...
</div>
On desktop and tablet screens, the first div appears to the left of the second div, as we would expect. On smaller screens, the first div appears on-top of the second div, again, as we would expect. What I'm wondering is.... Is it possible, on smaller screens, to flip the order of these two so that the second div appears on top of the first?
Sure! This is built into Bootstrap version 3, with classes like col-[size]-push-[cols], as in the column ordering section of Bootstrap's documentation
Demonstration in this fiddle, using the below code based on Bootstrap's example.
<div class="container-fluid">
<div class="row">
<div class="col-sm-9 col-sm-push-3">First on mobile, second on desktop</div>
<div class="col-sm-3 col-sm-pull-9">Second on mobile, first on desktop</div>
</div>
</div>

first column of a row to bottom side on mobile view boostrap 3

I have two columns in a row.
<div class="row">
<div class="col-lg-2">
I want this column in bottom side on mobile.
</div>
<div class="col-lg-8">
I want this column in top side on mobile.
</div>
</div>
When I visualize this on my laptop, they are in left and right side respectively. When I watch the page on my mobile phone I see first column on top of the web page.
I want to change the order, first column left side on laptop and bottom side on mobile phone instance of first column that is left side on laptop and top side on mobile phone.
I want to keep the laptop aspect, only change mobile phone view.
Check out the documentation of Bootstrap 3's grid system:
http://getbootstrap.com/css/#grid
By adding the *-lg classes you have only specified how your page should behave on a large screen.
You probably want to add the *-xs classes for defining the columns in the smartphone widths. You can keep the *-lg classes just as they are now.
Furthermore, for changing the order of columns in different widths, bootstrap provides *-push and *-pull classes, see here: http://getbootstrap.com/css/#grid-column-ordering
add class to the larger div .pull-left, and smaller div .pull-right
<div class="row">
<div class="col-lg-2 pull-right">
I want this column in bottom side on mobile.
</div>
<div class="col-lg-8 pull-left">
I want this column in top side on mobile.
</div>
</div>
This will float the second larger div to the left, and thus in the mobile view, where .col-lg-8 is not applicable, will bring it on top
Edit: As this answer creates a gap between two divs, because there are only 10 columns utilized
You will need to change your html see this http://jsfiddle.net/53u69ama/1/
<div class="row">
<div class="col-sm-8 col-xs-12 ">
I want this column in top side on mobile.
</div>
<div class="col-sm-2 col-xs-12 ">
I want this column in bottom side on mobile.
</div>
</div>
Edit 2: you can also change the top position using position style, but this will require you to set the static top for one div. Or you may change it using javascript dynamically.
see this http://jsfiddle.net/53u69ama/2/
Solution:
<div class="row">
<div class="col-lg-8 col-lg-push-2">
I want this column in top side on mobile.
</div>
<div class="col-lg-2 col-lg-pull-8">
I want this column in bottom side on mobile.
</div>
</div>
Use this
<div class="row">
<!-- this is visible if view is all less lg (on top) -->
<div class="device-xs visible-xs device-sm visible-sm device-md visible-md">
<div>
Content to view 2.
</div>
</div>
<div class="col-lg-2">
Content to view 1
</div>
<!-- this is visible when view is lg (in right) -->
<div class="col-lg-8 device-lg visible-lg">
Content to view 2.
</div>
</div>
Note that you will have to copy "Content to view 2." twice.

Resources