Reubenur Rahman
Reubenur Rahman

Reputation: 1

Can I define an exixting css class with different attribute in a different css class?

I have a CSS class to show the portlet title :

.portlet-title {
    color: #FFFFFF; 
    font: bold 12px Arial, Helvetica, Geneva, sans-serif;
}

In another css file I've a class :

.lfr-grid.dragging {
    border-collapse: separate;
}

now I want to call the class .portlet-title in .lfr-grid.dragging with changing the color attribute as color: #000000

Upvotes: 0

Views: 108

Answers (2)

deceze
deceze

Reputation: 522075

CSS is not about calling classes, it's about applying more or less specific styles.

Assuming a structure like this:

<div class="portlet-title">...</div>

which sometimes changes to this:

<div class="portlet-title lft-grid dragging">...</div>

you can simply apply a more specific style:

.portlet-title.lfr-grid.dragging {
    color: #000000;
}

Upvotes: 3

Cofey
Cofey

Reputation: 11404

You can accomplish this with the following:

.lfr-grid.dragging .portlet-title {
color: #000;
}

Note that .lfr-grid.dragging will not work in IE6 as it does not support chaining of classes.

Upvotes: 0

Related Questions