16th Jul '22
/
0 comments

Auto Responsive Grids in Bricks

This tutorial provides the CSS that can be pasted for automatic responsive grids in Bricks Builder.

Posts element

Each post will get a right padding (30px by default) in the default Grid layout but the space to the right for posts in the last column is undesirable.

Here’s the fix. Add the following at STYLE → CSS → Custom CSS:

root .bricks-layout-wrapper {
	margin-right: 0;
	margin-bottom: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	grid-column-gap: 30px;
	grid-row-gap: 30px;
}

root .bricks-layout-item {
	width: auto;
	padding-right: 0;
	padding-bottom: 0;
}

We are changing the display of the posts’ wrapper from flex to grid and setting the column width to be a minimum of 300px (you can change this to your liking) and a maximum of 1 fraction of the available width.

If you wish to have more control (being able to specify the columns at different breakpoints) and use a manual CSS Grid, we covered that in the CSS Grid for Posts Element in Bricks tutorial.

Query Loop

If you have enabled the query loop on a Container/Block/Div element, here’s the equivalent CSS to be added to the parent of the element for which query loop is applied:

root {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	grid-column-gap: 30px;
	grid-row-gap: 30px;
}
Get access to all 628 Bricks code tutorials with BricksLabs Pro

Leave the first comment

 

Related Tutorials..

Pro
6 Random Featured Posts in Alphabetical Order in Bricks

6 Random Featured Posts in Alphabetical Order in Bricks

How to output x number of random posts with a specific meta value set, in Alphabetical order.
Categories:
How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

This tutorial will explain how to enable the AJAX filter with an infinite scroll query loop container, how to add a sorting function, how to…
Categories:
Pro
How to Insert Element(s) Between Query Loop Posts in Bricks

How to Insert Element(s) Between Query Loop Posts in Bricks

Update on 16 Aug 2023: Follow this tutorial instead. This Pro tutorial shows how we can insert a Div (or any custom HTML) after nth…
Displaying SureCart Featured Products & Products Collections with a Query Loop

Displaying SureCart Featured Products & Products Collections with a Query Loop

We walk through how to use a query loop to display SureCart products, featured products & collections.
Categories:
How to display a Query Loop in 3 columns in Bricks

How to display a Query Loop in 3 columns in Bricks

This tutorial provides the builder settings and CSS codes that can be pasted in order to create a 3-columns query loop container inside Bricks Builder.
Categories:
How to add a layout toggle on query loops in Bricks

How to add a layout toggle on query loops in Bricks

In this tutorial, we’ll show you how to change the layout of your query loop container based on the click of an icon toggle sitting…
Categories:
Pro
Ordering Posts by Terms in Bricks

Ordering Posts by Terms in Bricks

How to output upcoming events at the top and past events below in a single query loop in Bricks.
Categories:
HappyFiles Bricks Query Loop

HappyFiles Bricks Query Loop

This tutorial explores different ways in which images from WordPress Media Library organized via HappyFiles can be pulled and shown in Bricks using query loop(s).…
Categories: