[personal profile] marama posting in [community profile] style_system
Hello. Having some trouble with the counting of entries and the nth-of-type pseudo-selector. I wanted to alternate the background colour of the entries and tried to use this:

div#entries > div.inner > div.entry-wrapper:nth-of-type(odd)
{ background-color: #35bf9d; } /*blue*/

div#entries > div.inner > div.entry-wrapper:nth-of-type(even)
{ background-color: #525dbf; } /*green*/

But instead of the blue colour being behind the first post, it's behind the second and the green is behind the first, basically swapping the colours opposite from the code. I played around with different formulas and what seems to be happening is the first entry is being counted as the second type, with the last counted as 21 instead of 20. So at this point, I'm lost. I know if I was doing a simple alternating pattern, I could just switch the colours and be done, but I was planning to use different equations to vary it, but with the odd counting, I can't be sure if the equations will work right now.

Any help is greatly appreciated. Thank you.

Date: 2012-09-05 10:51 pm (UTC)
marahmarie: (M In M Forever) (Default)
From: [personal profile] marahmarie
Afuna didn't say if she saw the odd behavior or not; you're saying it shows up in Stylish; I don't use Stylish and you're not using Web Dev so given all that, if I were you, my advice might be to just add the CSS to your DW directly to see if it works out as-is or not, since there's no way of telling otherwise. Afuna's statement on it does seem to support the idea that it could be wonky as-is, but the proof's in the pudding, I suppose...

Profile

Dreamwidth style system discussion

January 2026

S M T W T F S
    123
45678910
11121314151617
18192021222324
25 26 2728293031

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 31st, 2026 08:04 pm
Powered by Dreamwidth Studios