# Alternating Rows/template query loop

**URL:** <https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135>\
**Category:** How To\
**Created:** [May 25, 2022, 5:02am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135 "2022-05-25T05:02:40Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocbroadband](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/ocbroadband/32/1335_2.png) [@ocbroadband](https://forum.bricksbuilder.io/u/ocbroadband)\
**Post date:** [May 25, 2022, 5:02am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/1 "2022-05-25T05:02:40Z")

</div>

Hi,

I’m working on doing some migrations from E to B and I’m not quite sure how to achieve the following in B.

 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/3/31f07bf05abdfbc2d81c8f51981c5b8037f267fd.jpeg)

I want to use a single template and have it alternate(reverse) rows. I didn’t see an option for multiple templates, so I presume I’ll have to do it in the CSS, but I can’t for the life of me remember what the CSS is to do it.

On top of this, can I use a single template for multiple categories and have it only show those categories? I can’t seem to see how to have it only show the posts from a specific category if I remove the term. Then it shows all the posts. Can it do that, or do I have to create 3 different templates one for each category. Ugh.

Thanks for any advice.

Lyle

---

<div class="post-metadata">

**Author:** ![itchycode](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/itchycode/32/4542_2.png) [@itchycode](https://forum.bricksbuilder.io/u/itchycode)\
**Post date:** [May 25, 2022, 6:35am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/2 "2022-05-25T06:35:52Z")

</div>

Let says the direct parent element for the left column and right column for each row has a class named myContainer

Assume that myContainer style should be

```auto
.myContainer {

            display: flex;

        }

```

Just add one more css rule as below.

```auto
 .myContainer:nth-child(even) {

            flex-direction: row-reverse;
}

```

---

<div class="post-metadata">

**Author:** ![ocbroadband](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/ocbroadband/32/1335_2.png) [@ocbroadband](https://forum.bricksbuilder.io/u/ocbroadband)\
**Post date:** [May 25, 2022, 6:48am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/3 "2022-05-25T06:48:34Z")

</div>

Thanks. I got the code, but I’m probably not putting in the nth line correctly, or in the right location. I’ve tried to add it in custom CSS settings, and directly on the element as a class, and in the elements CSS properties, but it doesn’t appear to work so I guess I’m probably doing something wrong. If I edit the page in Dev tools and add it manually, it works. This is on a query builder div that I’m trying to do this. Here’s some images…

 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/d/de1ba4617dc23c9dc30b0ace187ce7797d584b82.png)  
 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/5/5edc1d361cf30944a5cb195a2f2760d6514ae7cd.jpeg)

---

<div class="post-metadata">

**Author:** ![itchycode](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/itchycode/32/4542_2.png) [@itchycode](https://forum.bricksbuilder.io/u/itchycode)\
**Post date:** [May 25, 2022, 9:23am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/4 "2022-05-25T09:23:42Z")

</div>

If you could provide a public accessible URL, I could take a look and see if can help 🙂

---

<div class="post-metadata">

**Author:** ![ocbroadband](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/ocbroadband/32/1335_2.png) [@ocbroadband](https://forum.bricksbuilder.io/u/ocbroadband)\
**Post date:** [June 23, 2022, 3:42am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/5 "2022-06-23T03:42:56Z")

</div>

@itchycode Sorry, had a slight sidetrack for a while on this. Here’s my test page I made.

[https://stage.madidovefilms.com/template/video-test-layout/](https://stage.madidovefilms.com/template/video-test-layout/)

I have this in my settings → CSS

.alternate-rows:nth-child(even) {  
flex-direction: row-reverse;  
}

And I have the class attached to my loop container.

 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/3/3b57ceb5a9d923bb4aef08a9e027c50104f55a58.jpeg)

Tried to work this out on my own for the last week, but I’m not getting it.

---

<div class="post-metadata">

**Author:** ![itchycode](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/itchycode/32/4542_2.png) [@itchycode](https://forum.bricksbuilder.io/u/itchycode)\
**Post date:** [June 23, 2022, 4:39am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/6 "2022-06-23T04:39:52Z")

</div>

Hi, the link is not accessible.

May I know are you turning on the Use Query Loop on the Loop Container with .alternative-rows class div?

If yes, you should select the Video Section (The loop parent), and in the Style CSS field, try this

```auto
root .alternate-rows:nth-child(even) {
	flex-direction:row-reverse;
}

```

 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/d/d76aaab7542b21f64c7a9f74c68e251af3ea803a.png)

 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/0/0aff0f7544c1397ae111751e2d42c61f6b25326c.png)

---

<div class="post-metadata">

**Author:** ![ocbroadband](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/ocbroadband/32/1335_2.png) [@ocbroadband](https://forum.bricksbuilder.io/u/ocbroadband)\
**Post date:** [June 23, 2022, 1:50pm UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/7 "2022-06-23T13:50:11Z")

</div>

That did it putting the CSS in the parent container. I’m curious why I can’t add it to the custom CSS area in the settings though?

---

<div class="post-metadata">

**Author:** ![itchycode](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/itchycode/32/4542_2.png) [@itchycode](https://forum.bricksbuilder.io/u/itchycode)\
**Post date:** [June 23, 2022, 11:43pm UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/8 "2022-06-23T23:43:39Z")

</div>

If you want to put into settings custom CSS field. You just need to inspect the parent ID #brxe-xxxx or add a class to the parent then write like this.

```auto
/*Bricks ID way*/
#brxe-xxxxx .alternate-rows:nth-child(even) {
	flex-direction:row-reverse;
}

/*Class way*/
.alternate-rows-parent .alternate-rows:nth-child(even) {
	flex-direction:row-reverse;
}

```

---

<div class="post-metadata">

**Author:** ![ocbroadband](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/ocbroadband/32/1335_2.png) [@ocbroadband](https://forum.bricksbuilder.io/u/ocbroadband)\
**Post date:** [June 25, 2022, 11:55pm UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/9 "2022-06-25T23:55:17Z")

</div>

@itchycode One more question on this if I may. How can I ‘remove’ the alternate at a specific break point. I’m wanting it to revert to a stacked view, but it appears to still be using reverse-row in the smaller breakpoints so it doesn’t look quite right and I’m not sure how to ‘not’ use that. I tried going to the smaller break point, and removing the class, but it removes it for the entire element at all breakpoints.

Thanks,

---

<div class="post-metadata">

**Author:** ![itchycode](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/itchycode/32/4542_2.png) [@itchycode](https://forum.bricksbuilder.io/u/itchycode)\
**Post date:** [June 26, 2022, 12:46am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/10 "2022-06-26T00:46:39Z")

</div>

Try example below.  
Means only activate the CSS rules if the screen width bigger than or equal to 1024px (target only desktop)

You could go search for media query in google for more tutorials 🙂

```auto
/*Bricks ID way*/
@media screen and (min-width:1024px) {
	#brxe-xxxxx .alternate-rows:nth-child(even) {
		flex-direction:row-reverse;
	}
}

/*Class way*/
@media screen and (min-width:1024px) {
	.alternate-rows-parent .alternate-rows:nth-child(even) {
		flex-direction:row-reverse;
	}
}

```

---

<div class="post-metadata">

**Author:** ![JohnGalt](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@JohnGalt](https://forum.bricksbuilder.io/u/JohnGalt)\
**Post date:** [March 29, 2023, 10:23pm UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/11 "2023-03-29T22:23:33Z")

</div>

I am using Grid–6 from ACSS… Will this work the same ?

---

<div class="post-metadata">

**Author:** ![itchycode](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/itchycode/32/4542_2.png) [@itchycode](https://forum.bricksbuilder.io/u/itchycode)\
**Post date:** [March 30, 2023, 7:25am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/12 "2023-03-30T07:25:14Z")

</div>

Hi John,

I am sorry that not familiar with that CSS class.  
You could provide your URL in the reply and elaborate what or which part you wish to achieve.  
We will assist.

Regards,  
Jenn

---

<div class="post-metadata">

**Author:** ![rtancer](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rtancer](https://forum.bricksbuilder.io/u/rtancer)\
**Post date:** [January 30, 2024, 2:47pm UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/13 "2024-01-30T14:47:30Z")

</div>

Itchycode - I have used your above advice in my site, however I am having a strange result.

This is my structure:

![image](https://forum.bricksbuilder.io/uploads/default/original/3X/e/5/e5e43cb9bc14347c99b98d9631557f40110aba9c.png)

I have applied the class to the Domestic Parent container:

 ![image](https://forum.bricksbuilder.io/uploads/default/original/3X/5/9/593c63f96fc2256a0f874af695ec95e72819160f.png)

This is the result:

 ![image](https://forum.bricksbuilder.io/uploads/default/original/3X/1/0/10c199f047c35d96a11ab5b996444a182a9b91bc.png)

It is good except for the entire middle column having the blue background.

Any ideas?

Thank you.

---

<div class="post-metadata">

**Author:** ![sinanisler](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/sinanisler/32/34468_2.png) [@sinanisler](https://forum.bricksbuilder.io/u/sinanisler)\
**Post date:** [September 17, 2025, 9:43am UTC](https://forum.bricksbuilder.io/t/alternating-rows-template-query-loop/3135/14 "2025-09-17T09:43:22Z")

</div>

starting from bricks 2.0+ selector detector now can solve this odd even selects for loop and alternate designs

short tutorial for different uses odd even and nth selections;

[![](https://img.youtube.com/vi/g_xyCcf7CjU/maxresdefault.jpg " - YouTube") ](https://www.youtube.com/watch?v=g_xyCcf7CjU)
