- This topic has 16 replies, 2 voices, and was last updated 2 years, 6 months ago by
Fernando.
-
AuthorPosts
-
February 13, 2023 at 11:52 pm #2532457
Hans-Gerd
Hello,
I am using GeneratePress Premium and GenerateBlocks (all up to date). The images should always be displayed square no matter at which device.
In (1) I used a grid with two containers. In (2) there are four containers.Unfortunately, I have not found a way that the images with the content they contain (texts, buttons, etc.) are always shown square in any case with best possible utilization of the viewport (please see here: https://test3.haurand.com/beispiel-slider/).
I would be glad if you can give me a tip.
Cheers,
Hans-GerdFebruary 14, 2023 at 12:02 am #2532469Fernando Customer Support
Hi Hans-Gerd,
To clarify, are you referring to removing the curves on the Containers?
If so, there’s a Border Radius set on the Container Block. You can remove this. Reference: https://docs.generateblocks.com/article/container-overview/#border-radius
If you’re referring to something else, let us know.
February 14, 2023 at 12:32 am #2532496Hans-Gerd
Hi Fernando,
thank you for the quick reply.Sorry, maybe I expressed myself wrong: The rounded corners should remain in any case, i.e. the entire container with the image should always be square.
Cheers,
Hans-GerdFebruary 14, 2023 at 12:49 am #2532508Fernando Customer Support
I see. Remove the empty Container Block for the spacer.
Remove the min-height you have set for the parent Container as well.
Then, add this CSS through Appearance > Customize > Additional CSS:
.gb-grid-wrapper.raster_ansicht > .gb-grid-column > .gb-container .kachel_blog{ aspect-ratio: 1 / 1; height: auto; width: 100%; } .gb-grid-wrapper.raster_ansicht > .gb-grid-column > .gb-container .kachel_blog > .gb-inside-container{ height: 100%; display: flex; flex-direction: column; } .gb-grid-wrapper.raster_ansicht > .gb-grid-column > .gb-container .kachel_blog > .gb-inside-container > :last-child{ margin-top: auto; }
This will force it to be square all the time.
You can also opt to wait for the upcoming update for GB which could come out hopefully by the end of the month. This new version has more settings. Theoretically, less CSS should be needed. Probably just this line:
aspect-ratio: 1 / 1;
February 14, 2023 at 2:27 am #2532597Hans-Gerd
Hi Fernando,
thanks again for the quick reply.
I still have to look at it in calm, implement it and then I will report again.Cheers,
Hans-GerdFebruary 14, 2023 at 5:04 am #2532752Hans-Gerd
Hi Fernando,
that works wonderfully now. Thanks again for the great help. 🙏Cheers,
Hans-GerdFebruary 14, 2023 at 5:08 pm #2533554Fernando Customer Support
You’re welcome, Hans-Gerd!
February 14, 2023 at 11:12 pm #2533695Hans-Gerd
Hi Fernando,
sorry, but I have another question, because unfortunately this does not work in the following case. You can see in the screenshot that depending on the viewport, the highlighted area is shown above the square (308.63px in the example ), so that overall there is no square view. I suspect that this is due to the container (“Eisenversorgung …” with the button below it) inside the element, which has a white transparent background.
The height of the upper area also varies depending on the width of the viewport (in the example it is 1046px).
(please see here: https://test3.haurand.com/beispiel-slider/)
Do you have a solution for this as well?Cheers,
Hans-GerdFebruary 14, 2023 at 11:18 pm #2533698Fernando Customer Support
Can you reshare the link to that page? The page shared doesn’t exist.
February 14, 2023 at 11:19 pm #2533699Hans-Gerd
sorry, this is the correct link: https://test3.haurand.com/beitrag-slider-sicherung/
February 14, 2023 at 11:32 pm #2533716Fernando Customer Support
Give the
kachel_blog
Container Block a different class:Example, if the class is
kachel_blog2
, the code for that would be:.gb-grid-wrapper.raster_ansicht > .gb-grid-column > .gb-container .kachel_blog2 { aspect-ratio: 1 / 1; width: auto; display: flex; flex-direction: column; justify-content: flex-end; }
February 15, 2023 at 12:16 am #2533736Hans-Gerd
Hi,
thanks a lot for answer, but unfortunately ist doesn’t work, see here:
Cheers,
Hans-GerdFebruary 15, 2023 at 12:42 am #2533749Fernando Customer Support
I see. The column width is restricting the width.
Can you remove the previous code you added here?: https://generatepress.com/forums/topic/always-show-square-images-in-grid/#post-2533716
Give that Grid Block a new different class as well. Let’s try to re-do it.
February 15, 2023 at 12:50 am #2533755Hans-Gerd
Hi,
thanks – I have assigned the CSS classraster_ansicht_2
to the grid. The right container has an additional CSS classkachel_log
(I have changed this temporarely for now).Cheers,
Hans-GerdFebruary 15, 2023 at 1:13 am #2533767Fernando Customer Support
Try this:
@media (min-width: 769px) { .gb-grid-wrapper.raster_ansicht_2 > .gb-grid-column { width: unset; } .gb-grid-wrapper.raster_ansicht_2 { flex-wrap: nowrap; } .gb-grid-wrapper.raster_ansicht_2 > .gb-grid-column:last-child { flex: 1 0 33%; } } .gb-grid-wrapper.raster_ansicht_2 > .gb-grid-column:last-child > .gb-container { aspect-ratio: 1/1; height: auto; }
-
AuthorPosts
- You must be logged in to reply to this topic.