/    Sign up×
Community /Pin to ProfileBookmark

nth-child loop from start of options

nth-child with large number of combinations…

I’m making a dynamic grid layout and displaying images on my screen.

I’m using nth-child to set how they should be positioned. it works for my first 7 DIV’s as it’s a 7 div pattern. But for my 8th it’s using the 4th not the 1st again.

How can I get around this?

` .pic:nth-child(1n){
background: #FFCC00;
grid-row: span 2;
grid-column: span 1;
}
.pic:nth-child(2n){
background: #22ec0f;
grid-column: span 2;
grid-row: span 1
}
.pic:nth-child(3n){
background: #f88417;
grid-row: span 2;
grid-column: span 1;
}
.pic:nth-child(4n){
background: #1f4124;
grid-column: span 1;
grid-row: span 1;
}
.pic:nth-child(5n){
background: #4de2db;
grid-column: span 1;
grid-row: span 1;
}
.pic:nth-child(6n){
background: #310e58;
grid-column: span 2;
grid-row: span 1;
}
.pic:nth-child(7n){
background: #eb245f;
grid-column: span 2;
grid-row: span 1
}
</style>`

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@KeverJun 15.2020 — With i going from 1 to 7.
.pic:nth-child(7n + i)
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...