td:nth-child(2) negation?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

td:nth-child(2) negation?

Felix Miata-2
Can a :not be used to make td:nth-child(2) not applicable if the element that
the td is a second child of is a td subjected to a colspan? If so, how?
--
"The wise are known for their understanding, and pleasant
words are persuasive." Proverbs 16:21 (New Living Translation)

 Team OS/2 ** Reg. Linux User #211409 ** a11y rocks!

Felix Miata  ***  http://fm.no-ip.com/
______________________________________________________________________
css-discuss [[hidden email]]
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: td:nth-child(2) negation?

Gautam Sathe

On Friday 28 July 2017 12:16 PM, Felix Miata wrote:
> Can a :not be used to make td:nth-child(2) not applicable if the element that
> the td is a second child of is a td subjected to a colspan? If so, how?

Hi Felix,

I have not tested this extensively for compatibility with all browsers -
but I believe something like this could do what you are looking for:

[code]
        td {
                background-color: red;
        }
        td:nth-child(2) {
                background-color: yellow;
        }
        td[colspan]:not([colspan="1"]) {
                background-color: green;
        }
        td[colspan]:not(:nth-child(2)) {
                background-color: black;
        }


Personally, I would not code such complex rules into CSS, I believe a
templating engine which applies logic at the server level would be a
saner choice.

What is the use case?

Regards
--
Gautam Sathe
______________________________________________________________________
css-discuss [[hidden email]]
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: td:nth-child(2) negation?

Eric A. Meyer
In reply to this post by Felix Miata-2
On 28 Jul 2017, at 2:46, Felix Miata wrote:

> Can a :not be used to make td:nth-child(2) not applicable if the
> element that
> the td is a second child of is a td subjected to a colspan? If so,
> how?

I confess to being a little bit confused here, because I read this as
you asking about a 'td' that's a child of another 'td' and I don't think
that's a thing.  Could you provide some markup samples to illustrate
cases where you do and don't want selection to occur?


--
Eric A. Meyer - http://meyerweb.com/
______________________________________________________________________
css-discuss [[hidden email]]
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: td:nth-child(2) negation?

Gautam Sathe
On Wednesday 02 August 2017 08:54 PM, Eric A. Meyer wrote:
> I confess to being a little bit confused here, because I read this as
> you asking about a 'td' that's a child of another 'td' and I don't think
> that's a thing.  Could you provide some markup samples to illustrate
> cases where you do and don't want selection to occur?

Apologies for jumping in uninvited :)

I believe what Felix meant is this:

He wants all td's that are nth child (2) i.e. the second TD of each TR
to be subjected to a particular rule EXCEPT if they also have a colspan.

i.e if a second TD has a colspan the rule should not apply.

I could have misunderstood his requirement of course - in which case the
code I sent last time would also be invalid.

Cheers
--
Gautam Sathe
______________________________________________________________________
css-discuss [[hidden email]]
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: td:nth-child(2) negation?

Philippe Wittenbergh

> On Aug 3, 2017, at 4:35 PM, Gautam Sathe <[hidden email]> wrote:
>
> On Wednesday 02 August 2017 08:54 PM, Eric A. Meyer wrote:
>> I confess to being a little bit confused here, because I read this as you asking about a 'td' that's a child of another 'td' and I don't think that's a thing.  Could you provide some markup samples to illustrate cases where you do and don't want selection to occur?

So am I :-). The one possibility that I could think of is a `td` **descendant** of another `td` - aka nested tables.

> I believe what Felix meant is this:
>
> He wants all td's that are nth child (2) i.e. the second TD of each TR to be subjected to a particular rule EXCEPT if they also have a colspan.
>
> i.e if a second TD has a colspan the rule should not apply.
>
> I could have misunderstood his requirement of course - in which case the code I sent last time would also be invalid.

That one is easy.

td:not([colspan]):nth-child(2) { background: lime; }

You could make the range narrower, e.g. td:not([colspan=2]):nth-child(2) {}

Philippe
--
Philippe Wittenbergh
https://l-c-n.com/






______________________________________________________________________
css-discuss [[hidden email]]
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: td:nth-child(2) negation?

Gautam Sathe
On Thursday 03 August 2017 02:12 PM, Philippe Wittenbergh wrote:
> td:not([colspan=2]):nth-child(2) {}

I missed the "=2" in the colspan :) Good to learn a new trick.

Thanks Philippe.
--
Gautam Sathe
______________________________________________________________________
css-discuss [[hidden email]]
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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: td:nth-child(2) negation?

Rob freeman
Please unsubscribe me from the list

[hidden email]



> On 3 Aug 2017, at 10:38, Gautam Sathe <[hidden email]> wrote:
>
> On Thursday 03 August 2017 02:12 PM, Philippe Wittenbergh wrote:
>> td:not([colspan=2]):nth-child(2) {}
>
> I missed the "=2" in the colspan :) Good to learn a new trick.
>
> Thanks Philippe.
> --
> Gautam Sathe
> ______________________________________________________________________
> css-discuss [[hidden email]]
> 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/

______________________________________________________________________
css-discuss [[hidden email]]
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/
Loading...