Re: proposal for a new css combinator

Tab Atkins Jr. wrote:
> On Thu, Jan 14, 2010 at 9:58 AM, James Elmore <James.Elmore@cox.net> wrote:

(snip)
>> What about allowing multiple limits? A combinator could let the depth of
>> control be stated, or limited by the designer.
>>
>> Just as an example, "h1 (1-2)h2" might select the first two levels of h2
>> elements under an h1 element.
>>
>> Even more, the (an+b) syntax might allow each nth child (or other
>> combinator) to be selected, so, for example, alternate headings could be
>> different colors.
>>
>> The use cases are the same as the thread which started this discussion, but
>> now with even more control.
>>
>> The question is: will implementation of this be too difficult or slow down
>> other CSS actions?
>>
>> Please be forgiving about the syntax, as I thought of the concept, but have
>> not had a chance to consider what might work best with the current syntax.
>> If anyone has a better suggestion for syntax, I would vote for it with no
>> hesitation.
> 
> The idea seems fine, but I'm not sure about implementation, and I'm
> not sure about how useful it would be compared to the main idea.
> first descendant is really useful, last descendant is pretty good too,
> but nth-descendant?  I'm certain there are uses for it, I just don't
> know if it's worth the effort to extend the syntax, without seeing any
> actual use-cases.
> 
> ~TJ


You want a use case.

<http://css-class.com/test/site-dev-beta1.htm>


div#wrapper2+div+div {
// style rules for footer //
}
#wrapper2+div+div p {
// style rules for p within footer //
}
#wrapper1+div+div  {
// style rules for clear //
}


can be changed to (I think),


div div:last-descendant+div+div+div {
// style rules for footer //
}
div div:last-descendant+div+div+div p {
// style rules for p within footer //
}
div div:first-descendant+div+div+div {
// style rules for clear //
}


or for the later,



div div:first-descendant:last-child {
// style rules for clear //
}


as the current tree stands.


-- 
Alan http://css-class.com/

Received on Thursday, 14 January 2010 17:24:31 UTC