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.
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.
no subject
Date: 2012-09-04 02:02 am (UTC)That is, the <div class="navigation"> at the very top counts as "1" in the numbering because it's of type div. It's not highlighted, however, because the class (.entry-wrapper) doesn't match.
The good news: that div is always printed, even when empty, so it'll be consistent when you're doing your calculations.
no subject
Date: 2012-09-04 02:15 am (UTC)In any event, your answered helped greatly as I was ready to pull some hair. Thank you!
no subject
Date: 2012-09-04 03:37 am (UTC)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!
no subject
Date: 2012-09-04 04:50 am (UTC)My first thought, of course, was why not just use .entry-wrapper-odd/.entry-wrapper-even to target the alternating colors, but if you want to vary the formula (like only applying a certain color to entries 3, 6, 9 and so on) then yeah, you'd definitely need nth-of-type to do that.
no subject
Date: 2012-09-04 05:23 am (UTC)Not really familiar with the programming aspect of S2, but hey, sounds like a good time to get my feet wet.
I agree there really are a lot of divs, but maybe to really isolate only the entries would be useful?
no subject
Date: 2012-09-04 05:27 am (UTC)I'm working locally with Stylish on Firefox, since that will more than likely be the css I post directly to DW, (adjusting for any image locations once I'm satisfied), and that's where I noticed the odd behaviour.
no subject
Date: 2012-09-05 10:51 pm (UTC)no subject
Date: 2012-09-07 07:11 am (UTC)(Adding a +1 offset would likely be easier though *g*)