tags:

views:

64

answers:

4

Hi!

I have a div:

    <div class="navigation mainPage"></div>

I need to specify that: every DIV that has a class "navigation" AND class "mainPage" should have "width: 999px".

Is this possible? thx

+4  A: 
.navigation.mainPage { width: 999px; }
Nimbuz
I have read an article that other browsers(specially old browsers don't support multiple css in a single element. Here is the link http://webdesign.about.com/od/css/qt/tipcssmulticlas.htm
jerjer
I meant multiple css classes in a single element.
jerjer
This does not work in IE6, not as intended. In IE6, this selector matches on the mainPage class only. See http://so.piskvor.org/1537692/ for a test case.
Piskvor
A: 

Try this:

.navigation, .mainPage{ width:999px; overflow:hidden;}
jerjer
That would make everything with the class navigation have a width of 999px. They only want the width set to 999px with the div has navigation and mainpage classes set.
rikh
They are classes not IDs so they should be `.navigation` and `.mainPage`.
James
#navigation means 'id="navigation"', not 'class="navigation"'; also, comma means "OR", as in "navigation or mainPage or both"
Piskvor
So what should be the correct one?
jerjer
Can you elaborate more on what's AND and OR in CSS?
jerjer
In my browser tests (IE8,FF3,Opera10), it seems that Nimbuz and Darth are correct, but see the IE6 caveat mentioned by Darth.
Piskvor
re OR: See http://www.w3schools.com/css/css_syntax.asp , header Grouping. E.g. ".class1, .class2" would match elements with class1 OR class2, whereas ".class1.class2" would only match elements with class1 AND class2, and ".class1 .class2" would match elements with class2 inside elements with class1.
Piskvor
Now, I know thank you very much for that info, I will note it.
jerjer
A: 

Since you want every DIV, make it more specific:

div.navigation, div.mainPage{ width:999px; overflow:hidden;}

Meera Tank
that's an OR, not an AND
Piskvor
Ah yes, good point :)
Meera Tank
+2  A: 

You can try

.navigation.mainPage { width: 999px; }

but this doesn't work in IE6. You can try to go around by doing

<div class="navigation navigation-mainPage"></div>

and then CSS

.navigation-mainPage { width: 999px; }

Even though this isn't the nicest solution, but I don't know of any other way around it.

Darth