00:00
Buy Me a Beer
CMS

Add custom style to Collection Items in Webflow (nth Child)

Easily add unique designs to Webflow CMS Collection Items with No-Code using nth Child

Blog Category G
Blog Category F
Blog Category E
Blog Category D
Blog Category C
Blog Category B
Blog Category A

Instructions

Firstly, make sure you have the VisualDX script before your </body>. Checkout the Quick Start for how to do this.

How to add nth child custom styles to a Webflow Collection Item

1

Copy this attribute:

Copied!
vdx-nth-child
2

Select the Collection List of a Webflow Collection

Collection List
Blog Category G
Blog Category F
Blog Category E
Blog Category D
Blog Category C
Blog Category B
Blog Category A
3

Paste the attribute into the Custom Attributes Name field of a Webflow Collection List

Collection List
Style
Settings
Interactions
Custom Attributes
Name
vdx-nth-child
Value
4

Add a Value to select the child element

eg. a Value of 3 selects the third element of the Collection Items.


Value 1 selects the first element of div siblings.

Value 2 selects the second element of div siblings.

etc, etc.

Collection List
Style
Settings
Interactions
Custom Attributes
Name
vdx-nth-child
Value
3
5

Copy this combo class:

Copied!
vdx--nth-child-
6

Paste the combo class into a style selector of your Collection Item and/or each the children of the Collection Item.

Add the Value from Step 4 to the end of the combo class.

In this example the Value is 3 therefore the combo class is:
vdx--nth-child-3


If vdx-nth-child has a value of 1, then the combo class is:
vdx--nth-child-1

If vdx-nth-child has a value of , then the combo class is:
vdx--nth-child-2

etc etc.

collection_item
Blog Category G
progress_bar
Style
Settings
Interactions
Style Selector
collection_item
vdx--nth-child-3
6

Style each of the combo classes.

eg. change the background color.

collection_item
Blog Category G
collection_item
Style
Settings
Interactions
Style Selector
collection_item
vdx--nth-child-3
Backgrounds
Image & Gradient
Color
#888680
7

Remove the combo class and Publish

Blog Category G
Blog Category F
Blog Category E
Blog Category D
Blog Category C
Blog Category B
Blog Category A

How to loop custom styles through Webflow Collection Items

1

Using a formula (an + b). Description: a represents an integer step size, n is all non negative integers, starting from 0, and b is an integer offset value.

Add a 5n+2 to the Value input to Style every 5th Collection Item starting at the 2nd Collection Item

Collection List
Style
Settings
Interactions
Custom Attributes
Name
vdx-nth-child
Value
5n+2
2

Add the combo class vdx--nth-child-5n-2 to the Collection Item and/or it's children

eg. change the background color.

collection_item
Blog Category G
collection_item
Style
Settings
Interactions
Style Selector
collection_item
vdx--nth-child-5n-2
Backgrounds
Image & Gradient
Color
#282828
3

Remove the combo class and Publish

Blog Category G
Blog Category F
Blog Category E
Blog Category D
Blog Category C
Blog Category B
Blog Category A

How to select multiple different nth child Webflow Collection Items

1

Add multiple values separated by commas in to the Value input.

Using the two previous examples we need to add 5n+2 followed by a comma and the number 3.

eg. 5n+2, 3

Collection List
Style
Settings
Interactions
Custom Attributes
Name
vdx-nth-child
Value
5n+2, 3
2

Publish

Blog Category G
Blog Category F
Blog Category E
Blog Category D
Blog Category C
Blog Category B
Blog Category A

Sponsor the Magic and
Buy Me a Beer

Ailín Tobin
Ireland

VisualDX is a free JavaScript library made for Webflow nerds like yourself. No ads, no paywalls—just pure, unfiltered JavaScript magic to supercharge your builds. If it’s saving you time, making your development easier, or just making you feel like a wizard in the Webflow Designer, consider slinging a virtual coffee my way.

Think of it like buying me a pint for keeping your Webflow spells flowing.

You can support it here.

Cheers, legend!

This is a method based on community and soundness. If you can't afford it, don't worry... One of your fellow Webflow nerds has already helped you out by donating.