Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible responsive grid in Gantry5? #3292

Open
lipatovroman opened this issue Dec 15, 2024 · 2 comments
Open

Flexible responsive grid in Gantry5? #3292

lipatovroman opened this issue Dec 15, 2024 · 2 comments

Comments

@lipatovroman
Copy link

lipatovroman commented Dec 15, 2024

Hello.
For example, in category view we have 3 cards in a row.
2024-12-15 15-53-43
So we use HTML code for that:
<div class="g-block size-33 padding2">
In this case, we get 3 cards in a row with these breakpoints: 75rem, 60rem, 48rem.
And then, we get 1 card in a row if screen width less than 48rem.
How to show 2 cards in a row in 60rem and 48rem breakpoints?
We need 3,2,1 cards in a row depending on current screen width.

This is how we can do it with bootstrap:
<div class="col-lg-4 col-md-6 col-12 mb-4">

@pablop76
Copy link

pablop76 commented Dec 18, 2024

Add css
@media screen and (max-width: 900px){
.size-33 {
flex: 0 50%;
width: 50%;
}

}
Include css specificity if you want to use only for a specific element (add a css class distinguishing it)

Using Media Queries Gantry
https://docs.gantry.org/gantry5/tutorials/media-queries

@lipatovroman
Copy link
Author

.size-33

Very good. Thank you.
Maybe this will be useful for someone. Here's what it looks like:

/*BOF Custom Gantry5 Grid for App Cards;*/ @media (max-width: 75rem) and (min-width: 60rem) { .appcard.size-33 { flex: 0 0 33.3333%; width: 33.3333%; } } @media (max-width: 60rem) and (min-width: 48rem) { .appcard.size-33 { flex: 0 0 50%; width: 50%; } } @media (max-width: 48rem) and (min-width: 42rem) { .appcard.size-33 { flex: 0 0 50%; width: 50%; } } @media (max-width: 42rem) { .appcard.size-33 { flex: 0 0 100%; width: 100%; } } /*EOF Custom Gantry5 Grid for App Cards;*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants