Drop Down Menu Tutorial, CSS + xHTML only, no JS
05-31-2007, 07:37 AM
|
Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 74
Name: Nick Barrett
Location: Brighton
|
I've seen quite a few people asking about this and it really is easy. Basically you have your ul with li's within and then ul and li's within that:
HTML Code:
<ul id="menu">
<li>A lovely Tab
<ul><li>sub tab #1</li>
<li>sub tab #2</li>
</ul>
</li>
<li>A lovely Tab#2
<ul><li>sub tab #21</li>
<li>sub tab #22</li>
</ul>
</li>
OK, that's pretty simple. Now you need to hide the extra ul's, make the primary tabs form horizontally. So we add this to the css:
Code:
ul { /*this applies to all ul tags*/
margin: 0; padding: 0; /*stops them moving around too much*/}
ul#menu li { list-style: none; float: left; padding: 5px; }
ul#menu li ul { display: none; /*hides the submenu clever bit now:*/
position: absolute; top: auto; left: auto; /*makes it appear below the item*/ }
/*now we need to show it on hover*/
ul#menu li:hover ul { display: block; }
/*now we style the sub menus li's*/
ul#menu li ul li { display: block; float: none; /*makes them appear on top of each other*/ }
Want proof it works or an example, the exact code is on this page:
http://kerplunc.com/projects/_css/drop_down_menu.php
[WARNING: do not copy that page directly, it has no <body> or <head> or <html> set up properly, it is just for testing]
Enjoy...
EDIT: I've returned, willing to help some more, bumped the thread, more examples coming soon, possibly some css thrown in/whatever.
__________________
Fanatical Host
24/7 Support | 99.5% uptime | shared | reseller | dedicated
Looking for a webhost? Try Host Scout!
Last edited by Political Monst; 12-26-2007 at 10:41 PM..
|
|
|
|
06-01-2007, 12:32 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 762
Name: DaveBob Roundpants III
Location: Heredia, Costa Rica
|
Hi Nick,
Out of curiosity I went to the page... no menu just some text.
|
|
|
|
06-01-2007, 12:59 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 8,823
Location: Tennessee
|
What are you talking about ? If you pass your mouse over the text, you'll see his drop down.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
|
|
|
|
06-01-2007, 06:52 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 74
Name: Nick Barrett
Location: Brighton
|
Sorry, they are the menu, you have to hover over them, I didn't style them at all because people can do that themselves, maybe I should link them though?
__________________
Fanatical Host
24/7 Support | 99.5% uptime | shared | reseller | dedicated
Looking for a webhost? Try Host Scout!
|
|
|
|
06-01-2007, 02:50 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 8,823
Location: Tennessee
|
This is good Nick, I'm gonna make it a stickie 
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
|
|
|
|
06-01-2007, 02:54 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 74
Name: Nick Barrett
Location: Brighton
|
Awesome, thanks ^^, should I post a message saying that I haven't styled the links?
__________________
Fanatical Host
24/7 Support | 99.5% uptime | shared | reseller | dedicated
Looking for a webhost? Try Host Scout!
|
|
|
|
06-01-2007, 09:13 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 8,823
Location: Tennessee
|
I think you just did 
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
|
|
|
|
06-01-2007, 10:04 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 74
Name: Nick Barrett
Location: Brighton
|
guess so lol  , thanks for making it a sticky again
__________________
Fanatical Host
24/7 Support | 99.5% uptime | shared | reseller | dedicated
Looking for a webhost? Try Host Scout!
|
|
|
|
06-03-2007, 09:20 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 74
Name: Nick Barrett
Location: Brighton
|
oops, broke the link, it's fixed now everyone ^^
__________________
Fanatical Host
24/7 Support | 99.5% uptime | shared | reseller | dedicated
Looking for a webhost? Try Host Scout!
|
|
|
|
06-04-2007, 02:34 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 7
Name: larry
|
Great menu layout! But, not in IE.. 
__________________
Life on Mars..?
Not since we left.
|
|
|
|
06-04-2007, 03:43 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 74
Name: Nick Barrett
Location: Brighton
|
I'm on a mac so I can't test it, however, which version of IE is this? If 7 then I can make a workaround if 6 then probably not.
__________________
Fanatical Host
24/7 Support | 99.5% uptime | shared | reseller | dedicated
Looking for a webhost? Try Host Scout!
|
|
|
|
06-10-2007, 01:18 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 29
Name: Efthimios Arvanitis (call me Mike)
|
Short, sweet, and to the point. Nice little code snippet.
__________________
█ URLhost.NET : SHARED & RESELLER · VPS & DEDICATED · DOMAIN NAMES · SERVER MANAGEMENT
█ PHP 4 & 5 · cPanel · Fantastico · RVSkin · Flash Tutorials · WHM-Reseller · FREE Billing Software!
|
|
|
|
06-30-2007, 02:43 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 29
Name: Efthimios Arvanitis (call me Mike)
|
This does NOT work for Internet Explorer. Very disappointing. I will attempt to fix that...
__________________
█ URLhost.NET : SHARED & RESELLER · VPS & DEDICATED · DOMAIN NAMES · SERVER MANAGEMENT
█ PHP 4 & 5 · cPanel · Fantastico · RVSkin · Flash Tutorials · WHM-Reseller · FREE Billing Software!
|
|
|
|
06-30-2007, 05:59 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 8,823
Location: Tennessee
|
No need.. IE 6 and older only supports the hover on the <a> tag. To solve that, you can use a behavior, called 'whatever hover". You can get the .htc file and the explanation here: http://www.xs4all.nl/~peterned/csshover.html
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
|
|
|
|
07-01-2007, 04:14 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 854
Name: Justice McCay
Location: New Jersey
|
Quote:
Originally Posted by LadynRed
No need.. IE 6 and older only supports the hover on the <a> tag. To solve that, you can use a behavior, called 'whatever hover". You can get the .htc file and the explanation here: http://www.xs4all.nl/~peterned/csshover.html
|
**** IE!  !
|
|
|
|
07-01-2007, 05:58 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 60
Name: bilton
|
not working on IE. only some text is displyed
rgds
bil
|
|
|
|
07-05-2007, 10:48 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 1
Name: Brock Cook
Location: South Australia, Australia
|
i just tried it on my webpage and Tested it without uploading it to a server and worked fine, still trying to figure out to align it to the Right and how to make it drop under and not to the Right of it.
__________________
HTML Pro, but the PHP Newbie.
|
|
|
|
07-07-2007, 03:03 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 3,024
Name: Forrest Croce
Location: Seattle, WA
|
Quote:
Originally Posted by LadynRed
No need.. IE 6 and older only supports the hover on the <a> tag.
|
Ahem. IE 666.
|
|
|
|
07-07-2007, 03:38 PM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 74
Name: Nick Barrett
Location: Brighton
|
Quote:
Originally Posted by ForrestCroce
Ahem. IE 666.
|
lol sorry 'bout IE guys, it just sucks, but as previously stated, a work-around is available for those who insist on using the evil browser (and for those who want to let their IE visitors see the site properly  ).
__________________
Fanatical Host
24/7 Support | 99.5% uptime | shared | reseller | dedicated
Looking for a webhost? Try Host Scout!
|
|
|
|
07-17-2007, 11:56 AM
|
Re: Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
Posts: 3
|
why do you use ul? I'm new in this field so I was wondering why didn't you use ol?
|
|
|
|
|
« Reply to Drop Down Menu Tutorial, CSS + xHTML only, no JS
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|