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 610 Bricks code tutorials with BricksLabs Pro

Leave the first comment

 

Related Tutorials..

Pro
Posts Grouped by Authors in Bricks

Posts Grouped by Authors in Bricks

This Pro tutorial for Bricks users provides the steps to loop through users and inside that, through posts whilst setting the inner query's author parameter…
Pro
Post ID Query Variable-based Post Output in Bricks

Post ID Query Variable-based Post Output in Bricks

How to query a single post of a custom post type using the post ID passed to a page via a URL parameter.
Pro
Upcoming Events with ACF Date Sub field Repeaters grouped by Month Years in Bricks

Upcoming Events with ACF Date Sub field Repeaters grouped by Month Years in Bricks

In the comments section of Upcoming Events Accordion in Bricks Grouped by 'Month Year' a member asked: CPT: eventACF Field: event_dates (Repeater) with event_date sub…
Categories:
Load more for Query loops in Bricks

Load more for Query loops in Bricks

Did you know that Bricks has AJAX loading for query loop posts on-click out of the box?
Categories:
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:
Pro
Filtering posts by a group field’s subfield value with Meta Box when using a custom table in Bricks

Filtering posts by a group field’s subfield value with Meta Box when using a custom table in Bricks

Filtering a query loop to output only those posts with the value of a Select subfield of a Group field set to Yes when using…
Categories:
Tags: