[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-04 03:37 am (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
Hmm, I don't think you'll need to worry about the bottomnav div, because it comes after everything else so won't affect the counting of anything before that.

I am not absolutely sure (would have to test), but I strongly believe that the same would be the case with nth-child.


PS. If you're touching S2 in addition to CSS, you can try overriding RecentPage::print_body. If not, then adjust your formulas a bit.

I'm wondering if it's worth adding another div around just the entries for all layouts in general, but there's so many divs already!

Date: 2012-09-07 07:11 am (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
I've been thinking about this one, and been on the fence, because on the one hand I see your point. On the other hand, we have so many wrappers already, and this one (at least) can be worked around... So Im leaning towards "no". But if you do need help figuring out how to work on s2 on your own, let me know!

(Adding a +1 offset would likely be easier though *g*)

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 05:54 pm
Powered by Dreamwidth Studios