纯css多级下拉菜单 可以遮住表单 支持IE6
外国人写的纯css多级下拉菜单,可以遮住表单,支持IE5.5, IE6, IE7, IE8, Firefox, Safari(PC), Opera and Google Chrome …
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title> Stu Nicholls | CSSplay | Menu with sub levels over select boxes iframe fix for IE6 method 4</title> <meta name="Keywords" content="cssplay, css, play, Cascading, Style, Sheets, experiments, demonstrations, menu, horizontal, dropdown, drop, multi, level, cross, browser, valid, professional, iframe, fix" /> <meta name="Description" content="CSS play - menu with sub levels over select boxes iframe fix for IE6 - method 4" /> <style type="text/css"> html {background:#f0f0f0} body {padding:0; margin:0; text-align:center; font-family:arial, sans-serif; font-size:76%;} #leftCol {min-height:200px; margin-top:10px; text-align:justify;} #leftCol p {font-size:13px; padding:0; margin:5px 0 0 3px; color:#333; line-height:20px;} #leftCol h3 {font-size:16px; font-weight:bold; color:#151; padding:10px 0 5px 0; margin:0 0 0 3px;} #form {width:700px; margin:30px auto;} #form legend {font-family:arial, sans-serif; color:#fff;} /* ================================================================ This copyright notice must be kept untouched in the stylesheet at all times. The original version of this stylesheet and the associated (x)html is available at http://www.cssplay.co.uk/menus/iframe-shim.html Copyright (c) Stu Nicholls. All rights reserved. This stylesheet and the associated (x)html may be modified in any way to fit your requirements. =================================================================== */ #menu {width:750px; height:531px; background:#2b3f5c; text-align:center; margin:0 auto;} #menu ul {margin:0; padding:0; list-style:none; white-space:nowrap; text-align:left; background:#ccccd0; border:1px solid #333; border-color:#eee #555 #222 #fff;} #menu ul {display:inline-block;} #menu li {margin:0; padding:0; list-style:none;} #menu li {display:inline-block; display:inline;} #menu ul ul {position:absolute; left:-9999px;} #menu ul.level1 {margin:0 auto;} #menu ul.level1 li.level1-li {float:left; display:block; position:relative;} #menu b {position:absolute;} /* -- for IE6 non-flyout dropdowns to stop flickering - who knows why --*/ #menu a {display:block; font:normal 11px verdana,arial,sans-serif; color:#000; line-height:25px; text-decoration:none;padding:0 20px;} #menu ul.level1 li.level1-li a.level1-a {float:left;} #menu ul li:hover > ul {visibility:visible; left:0; top:21px;} #menu ul ul li:hover > ul {visibility:visible; left:100%; top:auto; margin-top:-25px; margin-left:-4px;} #menu li.left:hover > ul {visibility:visible; left:auto; right:0; top:25px;} #menu li.left ul li:hover > ul {visibility:visible; left:auto; right:100%; top:auto; margin-top:-25px; margin-right:-4px;} #menu a:hover ul {left:0; top:23px;} #menu li.left a:hover ul {left:auto; right:-1px; top:23px;} #menu li.left ul a {text-align:right;} #menu a:hover a:hover ul, #menu a:hover a:hover a:hover ul {left:100%; visibility:visible;} #menu li.left a:hover a:hover ul, #menu li.left a:hover a:hover a:hover ul {left:auto; right:0; visibility:visible;} #menu a:hover ul ul, #menu a:hover a:hover ul ul {left:-9999px;} #menu li.left a:hover ul ul, #menu li.left a:hover a:hover ul ul {left:-9999px;} #menu li a.drop {background:transparent url(t1-down.gif) no-repeat right center;} #menu li a.fly {background:transparent url(t1-right.gif) no-repeat right center;} #menu li.left ul a.fly {background:transparent url(t1-left.gif) no-repeat left center;} #menu li a:hover, #menu li a.fly:hover {color:#c60; background-color:#c0c0c8;} #menu li:hover > a, #menu ul li:hover > a.fly {color:#c60; background-color:#c0c0c8;} #menu table {position:absolute; height:0; width:0; left:0; border-collapse:collapse; margin-top:-6px;} #menu table table {position:absolute; left:99%; height:0; width:0; border-collapse:collapse; margin-top:-30px; margin-left:-4px;} #menu li.left table {position:absolute; height:0; width:0; left:auto; right:0; border-collapse:collapse; margin-top:-4px;} #menu li.left table table {position:absolute; left:auto; right:100%; height:0; width:0; border-collapse:collapse; margin-top:-30px; margin-right:-4px;} </style> <!--[if lte IE 7]> <style type="text/css"> #menu ul {display:inline;} </style> <![endif]--> <!--[if lte IE 6]> <style type="text/css"> #menu ul ul {_azimuth: expression(this.shimmed = this.shimmed || 'shimmed:'+this.insertAdjacentHTML('beforeBegin','<iframe src="javascript:'+"''"+'" style="filter:alpha(opacity=0); padding:0; margin:0; border:0;"></iframe>'),'inherit');} #menu iframe {position:absolute; left:-9999px; top:0;} #menu :hover iframe {left:expression(this.nextSibling.offsetLeft);top:expression(this.nextSibling.offsetTop);width:expression(this.nextSibling.offsetWidth);height:expression(this.nextSibling.offsetHeight);} </style> <![endif]--> </head> <body> <div id="menu"> <ul class="level1"> <li class="level1-li"><a class="level1-a" href="#url">Home</a></li> <li class="level1-li"><a class="level1-a drop" href="#url">Contact Us<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level2"> <li><a href="#url">Email</a></li> <li><a href="#url">Telephone</a></li> <li><a href="#url">Online Form</a></li> <li><a href="#url">Snail Mail Address</a><b></b></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li class="level1-li"><a class="level1-a drop" href="#url">Resort<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level2"> <li><a href="#url">Ski Hire Facilities</a></li> <li><a class="fly" href="#url">Main Ski Slopes<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level3"> <li><a href="#url">Beginners Slopes</a></li> <li><a href="#url">Intermediate Slopes</a></li> <li><a class="fly" href="#url">Advanced Skill Levels<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level4"> <li><a href="#url">Local</a></li> <li><a href="#url">Nearby</a></li> <li><a href="#url">With instructor</a></li> <li><a href="#url">Snow boarding</a><b></b></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li><a href="#url">Expert</a></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li><a href="#url">Night Life</a></li> <li><a class="fly" href="#url">Restaurants<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level3"> <li><a href="#url">Snow Hotel</a></li> <li><a href="#url">The Snowman</a></li> <li><a href="#url">Ice Cavern</a></li> <li><a href="#url">Ski Inn</a><b></b></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li><a class="fly" href="#url">Car Hire<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level3"> <li><a href="#url">From Airport</a></li> <li><a href="#url">In Resort</a></li> <li><a href="#url">Multiple Resorts</a><b></b></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li class="level1-li"><a class="level1-a drop" href="#url">Surrounding Area<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level2"> <li><a href="#url">Where to go</a></li> <li><a href="#url">What to do</a></li> <li><a href="#url">Places of interest</a></li> <li><a href="#url">National parks & Museums</a><b></b></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li class="level1-li left"><a class="level1-a drop" href="#url">Information<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level2"> <li><a href="#url">Money Exchange</a></li> <li><a class="fly" href="#url">Resort Essential Information<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level3"> <li><a href="#url">Lift Passes</a></li> <li><a href="#url">Insurance</a></li> <li><a class="fly" href="#url">Gear Rental<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level4"> <li><a href="#url">Boots</a></li> <li><a href="#url">Skis</a></li> <li><a href="#url">Ski Wear</a></li> <li><a href="#url">Goggles</a><b></b></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li><a href="#url">Ski Schools</a></li> <li><a href="#url">Snow Report</a></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li><a class="fly" href="#url">Language<!--[if gte IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="level3"> <li><a href="#url">Austrian</a></li> <li><a href="#url">German</a></li> <li><a href="#url">French</a></li> <li><a href="#url">English</a><b></b></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li><a href="#url">Short Breaks</a></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li class="level1-li"><a class="level1-a" href="#url">Privacy</a></li> </ul> <form id="form" action="..." method="post" onsubmit="alert('This is a test.');return false"> <fieldset> <legend>OPTIONS<br /><br /></legend> <select name="choice1"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> <select name="choice2"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> <select name="choice3"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> <select name="choice4"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> <br /><br /><br /> <select name="choice5"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> <select name="choice6"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> <select name="choice7"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> <select name="choice8"> <option selected="selected" label="none" value="none">none</option> <optgroup label="Group 1"> <option label="cg1a" value="val_1a">Selection group 1a</option> <option label="cg1b" value="val_1b">Selection group 1b</option> <option label="cg1c" value="val_1c">Selection group 1c</option> </optgroup> <optgroup label="Group 2"> <option label="cg2a" value="val_2a">Selection group 2a</option> <option label="cg2b" value="val_2a">Selection group 2b</option> </optgroup> <optgroup label="Group 3"> <option label="cg3a" value="val_3a">Selection group 3a</option> <option label="cg3a" value="val_3a">Selection group 3b</option> </optgroup> </select> </fieldset> <p> <input id="button1" type="submit" value="Send" /> <input id="button2" type="reset" value="Reset" /> </p> </form> </div> <div id="leftCol"> <h3>Information</h3> <p>Using the latest techniques for variable width dropdown/flyout menus in which the widths are set by the link text, this menu adds a fix for the IE6 select box bug so that the menu drops over the select boxes.</p> <p>Again this uses CSS expressions to add the iframes and style them to fit.</p> <p>To make the page validate I have moved the IE6 expression styling into a separate stylesheet, but this can be all in one if you are not worried about validation.</p> <p>Tested in IE5.5, IE6, IE7, IE8, Firefox, Safari(PC), Opera and Google Chrome.</p> </div> </body> </html> |