January 2, 201313 yr I'm trying to get a drop down menu to work, with drop down images. It's also got a rollover effect. I can get the rollover working fine, and if I use spry, I can get rollover or dropdown, but not both. the code for html and css is below, and I need to know why it's not working and how to fix it. I've been looking for answers for 3 months now, and trying various different things and learning multiple languages to try and solve this, but I just still have no clue. My most recent attempt was through a tutorial by Joren Rapini, and it's the closest I have come, as dreamweaver CS5 highlights the boxes where the drop down links should appear, but yet they don't when I hover over the drop link. A fix would be very much appreciated! HTML CODE IS HERE <div id="MyMenu"> <div id="navigation"> <ul> <li><a href="index.html" class="link1">Home</a></li> <li><a href="about.html" class="drop link2">About us<!--[if IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul> <li><a href="team.html" class="link7">Team</a></li> <li><a href="drivers.html" class="link8">Drivers</a></li> <li><a href="partners.html" class="link9">Partners</a></li> <li><a href="mission.html" class="link10">Mission</a></li> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> <li><a href="store.html" class="link3">Store</a></li> <li><a href="gallery.html" class="link4">Gallery</a></li> <li><a href="contact.html" class="link5">Contact</a></li> <li><a href="forum.html" class="link6">Forum</a></li> </ul> </div> CSS CODE IS HERE #MyMenu { position: absolute; width: 960px; height: 40px; left: 480px; top: 154px; overflow:visible; } #navigation { width:960px; height:40px; position:relative; z-index:100; float:left; } /* hack to correct IE5.5 faulty box model */ * html #navigation { width:160px; w\idth:159px; } /* float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */ #navigation li { width:160px; height:40px; position:relative; float:left } /* style the links for the top level */ #navigation a, #navigation a:visited { display:block; height:40px; background-image:url(../Images/Navbar/button%20bar.jpg); background-position:top left; text-indent:-9000px; } /* a hack so that IE5.5 faulty box model is corrected */ * html #navigation a, * html #navigation a:visited { width:160px; width:160px; } /* style the second level background */ #navigation ul ul a.drop, #navigation ul ul a.drop:visited { background-color:#000000; } /* style the second level hover */ #navigation ul ul a.drop:hover{ background-color:#000000; } #navigation ul ul :hover > a.drop { background-color:#000; } /* hide the sub levels and give them a positon absolute so that they take up no room */ #navigation ul ul { visibility:hidden; position:absolute; top:40px; left:0px; height:40px; width:160px; } /* another hack for IE5.5 */ * html #navigation ul ul { top:-9px; top:-10px; } /* style the table so that it takes no part in the layout - required for IE to work */ #navigation table { position:absolute; top:40px; left:160px; height:40px; border-collapse:collapse; } /* style the second level links */ #navigation ul ul a, #navigation ul ul a:visited { height:40px; width:160px; text-indent:-9000px; display:block; } /* yet another hack for IE5.5 */ * html #navigation ul ul a, * html #navigation ul ul a:visited { width:160px; width:160px; } /* style the top level hover */ #navigation :hover > a, #navigation ul ul :hover > a { background-image:url(../Images/Navbar/button%20bar.jpg); } /* top level image background placements */ #navigation a.link1:hover { background-position:0px 200px; } #navigation a.link2 { background-position:-160px 0px; } /* DO NOT consolodate next 2 lines into one, this breaks IE6 */ #navigation a.link2:hover { background-position:-160px 200px; } #navigation :hover > a.link2, #navigation ul ul :hover > a.link2 { background-position:-160px 200px; } #navigation a.link3 { background-position:-320px 0px; } #navigation a.link3:hover{ background-position:-320px 200px; } #navigation a.link4 { background-position:-480px 0px; } #navigation a.link4:hover { background-position:-480px 200px; } #navigation a.link5 { background-position:-640px 0px; } #navigation a.link5:hover { background-position:-640px 200px; } #navigation a.link6 { background-position:-800px 0px; } #navigation a.link6:hover { background-position:-800px 200px; } #navigation a.link7 { background-position:-160px -40px; } #navigation a.link7:hover { background-position:-160px -240px; } #navigation a.link8 { background-position:-160px -80px; } #navigation a.link8:hover { background-position:-160px -280px; } #navigation a.link9 { background-position:-160px -120px; } #navigation a.link9:hover { background-position:-160px -320px; } #navigaton a.link10 { background-position:-160px -160px; } #navigation a.link10:hover { background-position:-160px -360px; } Again, I'm willing to try anything or learn anything to get this to work, I just need pointing in the correct direction, and maybe walking through it. I have tried java, spry and css, I attempted to learn coldfusion and now I'm thinking of flash. Many thanks in advance! Note: I did save the tut image from Joren's site, and copied and pasted the code into new files, and yet the dropdown effect still didn't work, could it be something to do with my PC? I also uploaded it to my test file on the server, and still no luck. It can be viewed online here: http://www.ajrmotorsport.com/2013/Pages/Index.html
January 2, 201313 yr CSSplay have lots of drop down menus, all pure CSS (no javascript) and here is one with dropdown and rollover images: http://www.cssplay.c...ropdown-v4.html or this one which has rollovers for the drop down tabs http://www.cssplay.co.uk/menus/image_dropdown.html and look for others in http://www.cssplay.co.uk/menus/ See if you can work out how they did it and use the code for your menu. Edited January 2, 201313 yr by Wickham
January 2, 201313 yr #Header{ margin-left: 0px; position: relative; } #AJRMenu{ position: absolute; width: 960px; height: 40px; left: 0px; top: 154px; overflow:visible; } #navigation ul ul { display: none; position:absolute; top:40px; left:0px; height:40px; width:160px; } #navigation ul:hover ul { display: block; position:absolute; top:40px; left:0px; height:40px; width:160px; } I don't know why you used main container width 1920px??? Please make these changes. Hopefully your issues will be fix. Thanks Hem Edited January 2, 201313 yr by Hem
January 2, 201313 yr Author Thanks Wickham, I have seen that site before, and yes there are some amazing menu's. Unfortunately, I can't just pick a menu and steal it, I'm not that evil, and not do I have the cash to pay someone for a menu. Thats why I am trying to figure this out on my own, as website design isn't what I do, it's just something I need to have done. I have had a look at the snippets of code that I can get from those menu's, and I still can't get why my menu isn't working. Is it something to do with the way :hover is implemented? And Hem, the container is large, for now. I know it is. But I seriously doubt that the size of the container will interfere with the menu, since it's inside a container anyway, unless your suggesting it is something to do with the positioning? Thanks for your input, any help I get right now is very much appreciated.
January 2, 201313 yr Author Wickham, your a legend, I just found the CSS for the image menu, and I think I can see where I am going wrong. I'm gonna give it a try, and I'll post if I get stuck again.
January 2, 201313 yr Up-to my knowledge... there is no need to set large container.. just default container should be 960px, 940px, 980px, etc.. and margin 0 auto; Automatically it will center in any resolution. Did you tried to make changes in your old code which I suggested?
January 2, 201313 yr Author Up-to my knowledge... there is no need to set large container.. just default container should be 960px, 940px, 980px, etc.. and margin 0 auto; Automatically it will center in any resolution. Did you tried to make changes in your old code which I suggested? I'm not having trouble with centering, I'm having issues getting the drop down elements to show up.
January 2, 201313 yr Thanks Wickham, I have seen that site before, and yes there are some amazing menu's. Unfortunately, I can't just pick a menu and steal it, I'm not that evil, and not do I have the cash to pay someone for a menu. CSSplay menus are free for personal websites and some are free for commercial websites, (ask permission for commercial use and pay a small donation). Menus are designed for you to copy CSS and markup from the source code. Edited January 2, 201313 yr by Wickham
January 2, 201313 yr i completely agree with wickham, There are thousands of tools out there pre designed for you, it is not steeling it is open source, I think you will find most developers learnt web design through playing with other peoples plugins. I am certainly one of those people
January 2, 201313 yr also /* float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */ #navigation li { width:160px; height:40px; position:relative; float:left } requires a semi colon after the float left
January 2, 201313 yr also /* float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */ #navigation li { width:160px; height:40px; position:relative; float:left } requires a semi colon after the float left You don't need a semi-colon after the last rule/attr although I do still put them in Edited January 2, 201313 yr by mteam
January 2, 201313 yr You don't need a semi-colon after the last rule/attr although I do still put them in best practice
January 3, 201313 yr Author Thanks for the responses guys. I did pop a semi-colon on the rule after I found it, and I normally do put semi-colons after every rule, just a general mistake that time. I tried with the CSS from CSS play, both tweaked and un-tweaked and for some reason drop down menus just don't appear with rollovers for me. I also had a look at some CSS3 examples, and still got no where. So basically, I've given up, I've gone and re-designed the website that I'll be creating, and have gone for rollovers because at least I can still use images in place of text and backgrounds.
January 3, 201313 yr I tried with the CSS from CSS play, both tweaked and un-tweaked and for some reason drop down menus just don't appear with rollovers for me. I also had a look at some CSS3 examples, and still got no where. Are you using sprite images (combined images with the hover image above or below or at the side of the main image, like this one http://www.cssplay.c...nus/veg/veg.jpg )? from this menu http://www.cssplay.c...e_dropdown.html Edited January 3, 201313 yr by Wickham
January 3, 201313 yr Author I tried all sorts of different images, the easiest to work with is with all images on 1 picture, then moving to the correct position, and it works wonders on the rollover part, but it never dropped down. Splicing 1 picture into multiple images diddrop down once, but I couldn't get it to do a rollover effect at the same time. My new navigation however, now has 10 buttons along it, but I have managed to keep it looking smart.
Create an account or sign in to comment