I have an Rails app I am building with Foundation. I am having trouble figuring out how to display an arbitrary number of columns per row and keep it responsive in the small/medium/large layouts.
For example, lets say I have a model Department which has many Employees. I am trying to build the department page and display a list of the employees in the department. One department may have 10 employees. Another may have 6. It's arbitrary.
I want to do 4 columns in large, 2 columns in medium and 1 column in small. (See my wireframe below). However, the columns need to be wrapped in a div.row. This requirement means I have either of the following two situations:
Case #1 (jsfiddle) I have 2 elements per row and the large layout only gets 2 elements because it is getting cleared by the .row.
Case #2 (jsfiddle) I have 4 elements per row and the columns don't clear properly when in the 2-column, medium layout because there are 4 in a row.
This seems like it should be a pretty standard situation but I cant seem to figure it out. How do I do this? Is Foundation the wrong tool?
Media Queries and CSS might do the trick:
// medium
#media only screen and (min-width: 40.063em) and (max-width: 64em) {
.row > div:nth-child(2) {clear: left;}
}
With 4 elements per row
http://quirksmode.org/css/selectors/nthchild.html
http://foundation.zurb.com/docs/media-queries.html
Related
I'm currently having a problem trying to set to the left every sublist of the navigation bar so that it aligns correctly bellow every sublist if there is more than 6 columns, the problem happens from the 7th list. I'm using bootstrap and every sublist have a size of 2 (so from the 7th as it passes the 12 column size it moves down, as expected)
What I'm getting a result is
And the expected result is
Piece of code used per list:
<div class="sub-navigation-section col-md-2">Ul and li inside</div>
The CSS that is attempting to do the expected result is a Float:left;
Bootstrap uses a 12 column grid system so you won't be able to divide that up equally into 7 columns. You could do this by creating your own class that has a width of approx 14.285% (100/7) and the same properties as the bootstrap col-* classes (float left etc)... but remember you'll need to cater for different viewports etc
If you wont use javascript, you can alternatively use CSS3´s column-gap and column-width like in this example:
https://www.bootply.com/118335
It floats the boxes like waterfall layout. Hope this helps you.
I am trying to resolve this problem for day and I found solution, but it is not as I imagine and what I would like to have, so I am reaching for greater and smarter minds here :)
I have web shop that is showing one product per row on mobile layout, like here:
enter image description here
but I would like to see it two in a row. Now, this is the problem: in Configuration of Virtuemart, showing products per row is set to 3, because I would like to see 3 products per row on computer and desktop devices (also laptops and bigger tablets), so this is OK and everything works fine.
But on mobile devices, in template mobile.css this is set always to show 1 in a row.So I searched and I found code
.category-view .vm-col-3
that is set to width: 100%
When I insert this to 50% I get this:
enter image description here
I insert clear: noneand float: leftnothing happened. So I figure it out I have to find some .row code, because I see that this is 3 products in a row like it is set in Configuration, only now it is smaller and sorted like this, but still not like I would like to have.
Then, I found line that sets the row:
.category-view .browse-view .row
and inserted this line:
clear: none;
float: left;
width: 50%;
With this, results are the closest, but still not what I need.
Always when it ends 9 products, next 3 are one under another (3 products) and then again starts with two in a row and repeats after 9 products.
You can see it here (with mobile phone): box2.appleoprema.com/index.php/iphone6-maskice-i-zastita
Can someone tell me please, how to fix this?
I have try many ways and codes to figure this out, and after 3 days I just don’t know what to do anymore.
Thanks in advance for help.
Hi there after having a look it seems that the structure of the container is like this
row
col-1
col-2
col-3
row
etc...
so adding width: 50%; to the row messes up everything because there are 3 products assigned to each row.
What you can do is either have width: 33% to .product.vm-col.vm-col-3 for media="(max-width: 640px)" to display 3 products per row or leaving it as it is so that the column gets 100% of the width showing 1 product per row.
If you want to have 2 products per row for mobile display probably you should either check in the backend if there is such option or tweak the html of the component/module that you are using.
So here is an issue:
Web sites features 4 columns with descriptions, each inside the <p> element.
The problem: since text size differs by column, some columns are shorter than the others and when using a mobile phone or a tablet, they appear like this:
http://imgur.com/DZ7YKnz
How would one solve such issue? At first I have tried the min-height attribute but since there are so many resolutions, and sometimes I split into 4 instead of 2 columns per row, depending on device, setting min height for each resolution is a pain.
Is there any other way to do that?
Site: https://www.piere.lt
A solution could be using some javacript to equal the height of all columns; there are a lot of libraries like http://brm.io/jquery-match-height/
A suggestion: use pure-u-md-1-2 pure-u-lg-1-4 to show items 2 by 2 at lower resolutions
I've been working with Susy for a while now and came across a use case that I can't seem to figure out. The best way to explain it is to use Twitter as an example.
If you look on their site you'll see they use a three column standard layout with a break point at 1250. After that point is reached, the entire right most column 3 goes underneath column 1.
How is this done with pure CSS in Susy 2? When I look at twitter it seems like they are physically moving the content from column 3 into column 1. I'm assuming this is all done with JS but id rather do it a bit more clean. Ideas?
Looks like it was as simple as using breakpoint as another mixin for my columns. I simply added
#import "breakpoint";
#include breakpoint (new screen size here) {
.right span (5 of 13);
.left span (8 of 13 last);
.middle span (5 of 13);
}
I am trying to use nth-child to target 1,6, 7,10, 13 ect. and some style. I was targeting them individually but this wont work as the content will be automatically generated.
I have 1 large div followed by 2 small divs one above the other then the next row is the opposite 2 small and one large and this is to continue as content is added.
What would be my best option for achieving this ?
Below is the css i am using at the min:
div:nth-child(1),div:nth-child(6),div:nth-child(7),
div:nth-child(10),div:nth-child(13){
background:#000;
}
I have 1 large div followed by 2 small divs one above the other then the next row is the opposite 2 small and one large and this is to continue as content is added.
So the same situation repeats every 6 items. Using :nth-child(an+b), you now know that a=6.
2 elements are selected for each group of 6: 1 and 6 (and then 7 and 12 (not 10), 13 and 18, etc). To select the first one, b=1 is OK. To select the 6th one, b=0 or b=6 are OK
That leads to:
li:nth-child(6n+1),
li:nth-child(6n) {
/* sth different */
}
Codepen: http://codepen.io/anon/pen/cypAn
You should use nth-child if you just want to use CSS. See this article here. There is a nice table at the bottom that can help if you are a visual learner.