CSS classes within classes

M

Mark Smith

Hi,

Apologies if this is OT, but I could not find any active groups
dedicated to CSS-

Is it possible to define a css class with a particular style that will
only be applied when it is nested within another class? For example,
suppose I have 2 parent classes (type1, and type2) and 1 child class
(redtable):

<div class="type1"><div class="redtable">...</div></div>
<div class="type2"><div class="redtable">...</div></div>

I want the 2 "redtable" classes to be rendered completely differently
due to their contexts. I thought I could apply the following css:

..type1.redtable{...}

..type2.redtable{...}

But that doesn't have any effect at all.

(Note, I can't use IDs, because the PHP backend could dynamically
create any number of instances, each one needs a unique ID for the
javascript to work)

Thanks for any help
 
K

Kevin Scholl

Hi,

Apologies if this is OT, but I could not find any active groups
dedicated to CSS-

Is it possible to define a css class with a particular style that will
only be applied when it is nested within another class? For example,
suppose I have 2 parent classes (type1, and type2) and 1 child class
(redtable):

<div class="type1"><div class="redtable">...</div></div>
<div class="type2"><div class="redtable">...</div></div>

I want the 2 "redtable" classes to be rendered completely differently
due to their contexts. I thought I could apply the following css:

.type1.redtable{...}
.type2.redtable{...}

Close, just need a space, like so:

..type1 .redtable{...}
..type2 .redtable{...}

If you know that these classes will be assigned to DIVs, then you coul
be more specific:

div.type1 div.redtable{...}
div.type2 div.redtable{...}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top