IE6 and a CSS thing I've not seen before!

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
So, I've got a fairly nice little CSS layout going on right now, I shan't bore you with the details of how it works perfectly in decent browsers, you all know it does! IE6 doesn't appear to like me sharing class names on elements, which is really stupid!

markup:
Code:
<div class="colourbox orange">
	<img src="lib/img/orange/vehicleplates.gif" class="title"/>
	<img src="lib/img/productvehicleplates.jpg" class="product"/>
	<ul>
		<li>Customise Your Vehicle</li>
		<li>Great quality and great designs.</li>
	</ul>
	<form action="" method="get">
		<ul>
			<li><label>Search</label></li>
			<li><input type="text" name="search" class="noborder"/></li>
			<li><input type="image" class="image" src="lib/img/orange/search.gif"/></li>
		</ul>
	</form>
	<div class="button orange">
		<a href="#" class="create"><span class="hidden">Create My Plates</span></a>
	</div>
</div>

css:
Code:
/**box*/
div.colourbox {
	float: left;
	width: 173px;
	height: 277px;
	padding-right: 7px;
	background-repeat: no-repeat;
	background-position: left top;
	margin-right: 10px;
}
div.colourbox.orange {
	background-image: url(../img/orange/orangebg.png);
}
div.colourbox img.title {
	margin: 9px 0 0 7px;
}
div.colourbox img.product {
	margin: 3px 0 0 1px;
}
div.colourbox ul {
	margin: 14px 9px 0 8px;
	width: 154px;
	height: 78px;
	max-height: 78px;
}
div.colourbox ul li {
	color: #fff;
	padding: 0 0 0 17px;
	font-size: 0.9em;
	background-repeat: no-repeat;
	background-position: 0px 0px;
	line-height: 1.2;
}
div.colourbox.orange ul li {
	background-image: url(../img/orange/tick.gif);
}
div.colourbox.orange ul>li:nth-of-type(2) {
	margin-top: 30px;
}
div.colourbox form {
	margin: 0 !important;
}
div.colourbox form ul {
	overflow: hidden;
	margin: 7px 0 0 1px !important;
	height: auto;
	width: 171px;
}
div.colourbox form ul li {
	float: left;
	background-image: none !important;
	margin: 0 !important;
	padding: 0 !important;
}
div.colourbox form label {
	margin: 3px 15px 0 7px;
	display: block;
	font-size: 0.9em;
	color: #fff;
}
div.colourbox form input.noborder {
	margin: 2px 15px 0 0;
	width: 80px;
	font-size: 0.7em;
	border: none;
	background: none;
}
div.colourbox form input.image {
	margin-top: 1px;
}
/**button*/
div.button {
	height: 28px;
	max-height: 28px;
	overflow: hidden;
}
div.button a {
	background-repeat: no-repeat;
	background-position: center 8px;
	display: block;
	padding: 14px 0;
	float: left;
}
div.colourbox div.button {
	margin: 13px auto;
}
div.button.orange {
	background: url(../img/orange/button.png) no-repeat top left;
	width: 115px;
}
div.button.orange a.create {
	background-image: url(../img/orange/createmyplates.png);
	width: 115px;
}

how it should look:
20080625-mr4hp7yryujga4n8uwx3ngu5dr.jpg


how it looks in IE6
20080625-ntxq8j7kqerud3ftkks2qkyedf.jpg


as you can see, the button has adopted the background of its parent, which shares its class name (they share class names to ease my memory!). This isn't an issue in IE7, which is nice.

Has anyone come across this before? Is it not possible to nest and share classnames like this in IE6? Am I in the wrong here, semantically, should the classnames be different even though they're really only being used as identifiers? It's obviously not an issue to change the names around (mild pain), but I've not seen this behaviour before and I thought it notable.
 
oh is that what it is? weird that I've not come across any problem with it til now, it's something I use all the time!
 
Yeah, IE6 can't target something based upon it having two or more specific classes.

It sees this:
div.colourbox.orange { background-image: url(../img/orange/orangebg.png);}

as this:
div.orange { background-image: url(../img/orange/orangebg.png);}

If possible, your best bet is to just target the classes individually.
 
er.. surely multiclassing is just a case of <div class="foo bar"> would have both div.foo and div.bar applied, and nothing else?
 
yeah, but IE doesn't like you using selectors like div.foo.bar, which was quite annoying.

I've had a whole 3 days of CSS and it's been really fun :D
 
In my new job, I've been allowed to do it way more - I used to be a strictly PHP/MySQL person, but now I get to do loads of HTML, CSS and Javascript as well.

I'm assuming you're not being sarcastic, but I've been wrong before!
 
I've had a whole 3 days of CSS and it's been really fun :D

I've been a Windows forms and server side developer since I started my career.
My current project is a website and I'm learning to hate CSS and JavaScript with a passion!

I'd dabbled in them before for some little personal projects, but doing it on a proper professional project is a different ball game and it's doing my head in at the moment!
 
I'm assuming you're not being sarcastic, but I've been wrong before!

hehe, no I was being sarcastic - I thought you were too by saying it was fun!

The seemingly never-ending amount of fixes/hacks you have to use to get something to bloomin well line up in every browser perhaps makes it easy sarcasm-fodder.

Still, glad you weren't being sarcastic - it is one of the most satisfying things ever when you create something that looks great in every browser.
 
heh, no I love that sort of thing - I'm an anally retentive perfectionist at the moment and CSS seems to be feeding it quite nicely. Like I said, I use multiple stylesheets so I don't have to use hacks, it's the least frustrating way of doing things imho
 
Back
Top Bottom