On Tue, 11 Sep 2007, Jeff Jansen wrote:
> Is it possible to use CSS selectors to define repeating patterns of styles
> down a page?
Not the way you (and I and many other people) would like to. This question
most often arises in the context of tables: how do you specify alternating
background color for rows? There the answer is that (sticking to CSS as
currently defined and implemented, and not using client-side scripting)
you would have to a class attribute for all odd-numbered rows.
> Each paragraph would be colored as indicated, and there will always a
> pattern of 3 colored lines.
In this case, you minimally need a class attribute for every third row.
You could then style the other paragraphs using successor selectors
(p.first + p, p.first + p + p), but since these aren't supported by IE
6, it's best to use some more classes:
<div id="repeat">
<p class="first">...</p>
<p class="second">...</p>
<p>...</p>
<p class="first">...</p>
<p class="second">...</p>
<p>...</p>
<p class="first">...</p>
etc.
</div>
I've omitted a class attribute for the third paragraph in each set, since
you can first style all p elements the way you want those third paragraphs
to appear, then style p.first and p.second as desidered. For example,
#repeat p { color: #00f; background: white; }
#repeat p.first { color: #f00; background: white; }
#repeat p.second { color: #0f0; background: white; }
#repeat [what-goes-here] { color: #0f0; }
#repeat [and-what-goes-here] { color: #00f; }
>
> So my question is, what's the [what-goes-here] and [and-what-goes-here]?
>
> Jeff Jansen
> Portland, OR
> ______________________________________________________________________
> css-discuss [EMAIL PROTECTED]
> http://www.css-discuss.org/mailman/listinfo/css-d
> List wiki/FAQ -- http://css-discuss.incutio.com/
> List policies -- http://css-discuss.org/policies.html
> Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
>
--
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/