(zoveelste) CSS menu probs met IE6/IE7

Oke ik zal het zo technisch mogelijk uit te leggen.

Klant zeurt om menu wat niet werkt in IE7… heb ik een script gebruikt hiervoor… werkt hij weer niet in IE6.

De kuur van beide browsers was simpel: of het is bij 6 of het is bij 7: het menu gaat als je over de rollover ga schiet hij naar rechts waardoor hij buiten het scherm komt ipv eronder.

Dit is de bedoeling in beide IE’s:
[img:96053c6910]http://www.dreamix-design.com/Afbeelding%201.png[/img:96053c6910]

Basis code:
Er is een div waar het menu in moet draaien met de volgende css properties:

[code:1:96053c6910]#locaties { position:absolute;
background-image:url(…/images/locatiebg.png);
background-repeat: no-repeat;
width: 240px;
height: 40px;
left: 675px;
top: 0px;
padding: 0px 0px 0px 12px;
text-align: left;
}[/code:1:96053c6910]

Nu komt het menu zelf:

[code:1:96053c6910]
.locatie {
z-index:100;
margin:0px 0px 0px 0px;
padding: 0px;
}
/* remove all the bullets, borders and padding from the default list styling /
.locatie ul {
padding:0px;
margin:0px;
list-style-type:none;
}
.locatie ul ul {
margin:0px;
padding: 0px 0px 0px 10px;
}
/
float the list to make it horizontal and a relative positon so that you can control the dropdown locatie positon /
.locatie li {
float:left;
margin:0px;
padding: 0px;
}
/
style the links for the top level /
.locatie a, .locatie a:visited {
display:block;
font-size:11px;
text-decoration:none;
color:#fff;
width:216px;
height:10px;
border-width:1px 1px 0 0;
background:#758279;
padding-left:0px;
line-height:29px;
text-align: left;
}
/
a hack so that IE5.5 faulty box model is corrected */

  • html .locatie a, * html .locatie a:visited {
    width:139px;
    }

/* style the second level background */
.locatie ul ul a.drop, .locatie ul ul a.drop:visited {
background:#d4d8bd;

}
/* style the second level hover /
.locatie ul ul a.drop:hover{
background:#FFFFFF;
}
.locatie ul ul :hover > a.drop {
background:#FFFFFF;
}
/
style the third level background /
.locatie ul ul ul a, .locatie ul ul ul a:visited {
background:#FFFFFF;
}
/
style the third level hover */
.locatie ul ul ul a:hover {
background:#FFFFFF;
}

/* hide the sub levels and give them a positon absolute so that they take up no room /
.locatie ul ul {
visibility:hidden;
position:absolute;
height:0;
top:35px;
left:6px;
;
}
/
another hack for IE5.5 */

  • html .locatie ul ul {
    top:30px;
    top:31px;
    }

/* position the third level flyout locatie /
.locatie ul ul ul{
left:150px;
top:0;
width:150px;
}
/
position the third level flyout locatie for a left flyout */
.locatie ul ul ul.left {
left:-150px;
}

/* style the table so that it takes no ppart in the layout - required for IE to work */
.locatie table {position:absolute; top:0; left:0;}

/* style the second level links /
.locatie ul ul a, .locatie ul ul a:visited {
background:#FFFFFF;
border-top:1px solid #CCCCCC;
color:#000;
height:auto;
line-height:1em;
padding:5px 10px 5px 0px;
width:129px
/
yet another hack for IE5.5 */
}

  • html .locatie ul ul a{
    width:150px;
    width:129px;
    }

/* style the top level hover */
.locatie a:hover, .locatie ul ul a:hover{
color:#fff;
background:#949e7c;
}
.locatie :hover > a, .locatie ul ul :hover > a {
color:#fff;
background:#949e7c;
}

/* make the second level visible when hover on first level list OR link /
.locatie ul li:hover ul,
.locatie ul a:hover ul{
visibility:visible;
}
/
keep the third level hidden when you hover on first level list OR link */
.locatie ul :hover ul ul{
visibility:hidden;
}

/* make the third level visible when you hover over second level list OR link */
.locatie ul :hover ul :hover ul{
visibility:visible;
}
[/code:1:96053c6910]

Heeft iemand een idee hoe ik dus het menu netjes recht in [b:96053c6910] beide[/b:96053c6910] browsers kan krijgen?

Alvast bedankt!

Het lukt dus wel in één van beiden? Maak met PHP een check op browser en laat dan optie A of B genereren. 2 Stylesheets en met PHP de juiste laden, en met PHP de juiste HTML per situatie maken. Ikzelf kreeg het helemaal niet fiks dus IE-ers krijgen via PHP bij mij een heel ander menu.

[quote:a69f68abec="Martiniman"]Het lukt dus wel in één van beiden? Maak met PHP een check op browser en laat dan optie A of B genereren. 2 Stylesheets en met PHP de juiste laden, en met PHP de juiste HTML per situatie maken. Ikzelf kreeg het helemaal niet fiks dus IE-ers krijgen via PHP bij mij een heel ander menu.[/quote:a69f68abec]

Errrr… what about conditional comments?
Absoluut geen nood aan PHP hiervoor…

Zie:
http://www.quirksmode.org/css/condcom.html

Met die bedoeling dat je dus de stylesheets gaat inladen voor elke browser op basis van welke conditional comments gevolgd worden. Werkt enkel in IE op Windows en is dus uitermate geschikt voor dit probleem, andere browsers zullen het gewoon negeren.

PS: Dat betekent niet dat ik een mogelijK CSS oplossing van de hand doe.

[quote:2da9282e11="Martiniman"]Het lukt dus wel in één van beiden? Maak met PHP een check op browser en laat dan optie A of B genereren. 2 Stylesheets en met PHP de juiste laden, en met PHP de juiste HTML per situatie maken. Ikzelf kreeg het helemaal niet fiks dus IE-ers krijgen via PHP bij mij een heel ander menu.[/quote:2da9282e11]

Thanks voor snelle responce… maar heb je hier misschien een voorbeeld van de php browser check? Ben zelf namelijk niet de beste in php…

[quote:e2fb90c35b="Bitcrumb"] Errrr.. what about conditional comments? Absoluut geen nood aan PHP hiervoor...[/quote:e2fb90c35b] Wanneer OOK de html verschilt heb je daar toch geen fluit aan? Of kun je HTML ook doorspekken met dit soort comments? Bovendien vind ik CSS met die comments niet te pruimen. Onleesbare troep heb je dan. [code:1:e2fb90c35b]<?php $agent=$_SERVER["HTTP_USER_AGENT"]; if (strpos($agent,'MSIE') !== FALSE) { if (strpos($agent,'MSIE 7') !== FALSE) { include 'IE7.html'; } else { include 'IE6.html'; } } else { include 'mozilla.html'; } ?>[/code:1:e2fb90c35b]

Oke.. na menu #1027230 te hebben geprobeerd.. is het dan ook eindelijk gelukt.

Nu moet ik alleen nog CSS aanpassen en me opdracht gever vrolijk maken dat ik het morgen ga aanpassen…

Alsnog bedankt voor reacties martini en bitcrumb!
Slotje mag erop

@Martiniman Die conditionele commentaar kan ENKEL voorkomen in een HTML bestand. Dus _niet_ in je CSS bestand. Daarom ook dat je ze in dit geval in de <head> zou moeten plaatsen om zo verschillende CSS bestanden in te laden naargelang de browser. De opmerking dat het je code lelijker maakt gaat dus niet op.

Echter, presentatielogica in PHP steken is al helemaal fout!