CSS Question

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
Ok Dudes,

I don't know if this is possible, but is it possible to apply two classes too one div?

regards,
Zenax
 

dyfuse

Member
Messages
395
Reaction score
0
Points
16
I don't think that would be possible (but don't quote me on it)...At some stage, I'm sure one of the classes would be 'overwritten' by the other....


But I can think of many ways in which you could use this method though - but just differently:

**applying a class to a <div></div> element whilst having a different class for a <span></span> or <table></table> or other element....which is inside the original div element.

Code:
<div class="divclass">
         <span class="spanclass">Span Text</span>
</div>
 

Cubeform

New Member
Messages
339
Reaction score
0
Points
0
Yes, you can. And it's simpler than you think.
HTML:
<div class="class1 class2"></div>

Note that there is a space between the classes you want to implement.

Oh yeah, in your CSS files, if those two classes have conflicting declarations (e.g. class1 has a background colour of blue, class2 has a background colour of green), I'm pretty sure the second class would override the first one.
 
Last edited:

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
Tried that and it didn't work.
However problem has been solved!

Regards,
Zenax
 

dyfuse

Member
Messages
395
Reaction score
0
Points
16
Yes, you can. And it's simpler than you think.
HTML:
<div class="class1 class2"></div>

Note that there is a space between the classes you want to implement.

Oh yeah, in your CSS files, if those two classes have conflicting declarations (e.g. class1 has a background colour of blue, class2 has a background colour of green), I'm pretty sure the second class would override the first one.

I didn't actually know that you could do that....until it didn't work for Zenax...but interesting though
(Cubeform have you used this method before?)
 

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
Erm what this question was relevant for, was that I was using the curvycorners script to create curvy corners, and one of the methods is for it too look for a class with a certain name, and then I wanted a second class after that, but it didn't work.

However, I have solved the problem, by using the divs I want curved to have a class and a ID.

and the ones I don't curved, I just use a normal class!

Regards,
Zenax
 

dyfuse

Member
Messages
395
Reaction score
0
Points
16
Yeah, that worked!

I'd actually forgot about ID's - I think they only apply to one element (they can only be used once), with classes able to be used on multiple items.

But, what you've done is used that for very specific customisation of the elements on your page!
 
Top