Old 03-02-2005, 12:07   #1 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,363
IE Multiple Class Names

Code:
#someid.class1 { .. } #someid.class2 { .. }

IE doesn't seem to like this and only plays ball when you resort to:

Code:
.class1 { .. } .class2 { .. }

Any/All known workarounds/fixes would be welcomed
__________________
Random goodness at The Blog


Last edited by i_am_cam : 04-02-2005 at 11:32.
  Reply With Quote
Old 03-02-2005, 12:54   #2 (permalink)
pgo
i'm done, son
 
Join Date: Jan 2005
Posts: 12,262
Quote:
Originally Posted by i_am_cam
#someid.class1 { .. }
#someid.class2 { .. }

Does that even validate? Don't think I've ever seen that before...

Did you try...

Code:
#someid XXX.class {...}

Or are you applying an ID and a CLASS to an HTML element? Not sure if that's "kosher" (not to mention necessary)...I'd have to look it up.

It's exactly this sort of situation that makes me try to avoid classes (as in CSS classes ) - I just try to use nested IDs as much as possible. Sometimes you can't escape it, though.
  Reply With Quote
Old 03-02-2005, 14:23   #3 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,363
Quote:
Originally Posted by pgo
Or are you applying an ID and a CLASS to an HTML element? Not sure if that's "kosher" (not to mention necessary)...I'd have to look it up.

Yes i'm applying an id and a class to an element, and it's both necessary & a valid technique

i'm just wondering if anyone's managed to get this working in IE
__________________
Random goodness at The Blog

  Reply With Quote
Old 04-02-2005, 06:53   #4 (permalink)
d*d
Senior Member
 
d*d's Avatar
 
Join Date: Oct 2004
Location: Bristol
Posts: 3,155
#idname .classname { }
seems to play if there is a space between the two
  Reply With Quote
Old 04-02-2005, 07:46   #5 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,237
yeah you need a space inbetween don't you cam?
  Reply With Quote
Old 04-02-2005, 07:59   #6 (permalink)
stickmus
hmmm...
 
stickmus's Avatar
 
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,130
I see what you're doing.

Seems to only take the first definition. A quick and easy workaround is to use a double class instead of an id so:
.test.test2 {
background:#0F0;
color:#fff;
}
.test.test1 {
background:#000;
color:#fff;
}

with

<div class="test1 test">test</div>
<div class="test2 test">test</div>

works just as you want. Not sure that helps though, does it need to be an ID?.
  Reply With Quote
Old 04-02-2005, 11:27   #7 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,363
Code:
<div id="header" class="home">..</div> .. <div id="footer" class="home">..</div> #header { .... } #header.home { border-top: 5px solid #339886; background: url(images/head-home.jpg) #E0EAF4 no-repeat; } #footer { ... } #footer.home { border-top: 5px solid #339886; }

That's an example of what I was wanting to achieve, where there could be N amount of subclasses of #header and #footer. SB; both formats are valid (with/without a space) and fwiw neither work in IE, the Fox works with the way i've got it above. stickmus, cheers for the suggestion but double-classes doesn't allow me to reuse the same class name at different stages of my document and for different purposes which was my intention.
__________________
Random goodness at The Blog

  Reply With Quote
Old 04-02-2005, 11:52   #8 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,237
what you're doing does seem to work in IE for me, at least I think I understand what you're trying to do. However...

Aren't you really just overwriting #header with #header.home?

In that case would it be easier, rather than writing class="home" in the header, footer or where ever divs, to just give the body an individual class?

That way you could have .home #header { ... } or .otherpage #header { ... }.

it's officially friday night now though.
  Reply With Quote
Old 04-02-2005, 11:57   #9 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,363
giving the body a class.

i knew there'd be an easy way round this.

sb, i owe you a beer, and aye enjoy the weekend, i'm off to start getting drunk in 20 minutes
__________________
Random goodness at The Blog

  Reply With Quote
Old 04-02-2005, 12:09   #10 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,237
everything should be made easier on a friday.

I'm off to start making the girlfriend's tea in 20 minutes
  Reply With Quote
Old 05-02-2005, 23:20   #11 (permalink)
pgo
i'm done, son
 
Join Date: Jan 2005
Posts: 12,262
This made me slap my forehead. Your CSS...
Code:
#someid.someclass { }
...confused me as it looked like you were trying to apply a class to an ID. I saw that and I thought, "Huh?".

And then I realized I'm using the same thing on my site!!!
HTML Code:
<div id="content" class="home"> <div id="content" class="resume">
...and so on.

The lack of a space between #someid and .someclass confused me to no end. I guess I thought you were trying to apply a class to the ID and not the element.

Putting a space between the two should be fine.

Silly me.
  Reply With Quote
Old 07-02-2005, 10:09   #12 (permalink)
Brooklyn
Anarchist by Accident...
 
Brooklyn's Avatar
 
Join Date: Feb 2003
Location: Oxfordshire UK
Posts: 137
IE does have a parsing issue with this when using javascript to pass style values at any point say for colour switching! Other than that, I've never had an issue with #id.class

Isn't this where specifity/cascade comes in?

#id
.class {}
element#id {}
element.class {}
element#id.class {}
html>element#id.class {}
html>element#id.class [type=attribute] {}

Though today I discovered:

*{...}
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8