»
S
I
D
E
B
A
R
«
CSS Powered Menus: Can you believe it?
April 18th, 2008 by Nitesh

Ever had trouble with JavaScript based drop down menus?Do not fear! CSS-Menus are here!Yes, you read it right, completely CSS generated drop down menus. We, at Wallwisher, always try to minimize the JavaScript on our home page, so as to reduce the loading time, and hence came to birth CSS-Menus, a completely CSS based drop down menu. You can see the effects on our live site, before looking into the code…pic_01 Apr. 19So, let’s say you want to build a similar drop down menu, with the trigger text called “Click Here”, and three example links in the drop down. Here’s a sample code on how to do so…

 <ul class="dd_menu"> 
    <li>Click Here</li> 
    <li><a href="http://www.example.com">Example 1</a></li>
    <li><a href="http://www.example.com" >Example 2</a></li>
    <li><a href="http://www.example.com">Example 3</a></li> 
</ul>

 
<style> 
    .dd_menu li { display: none; } 
    .dd_menu li:first-child { display: block; }
    .dd_menu:hover li { display:block; }
</style>

 As you will notice, by default the <a> tags in the main span are hidden. However, on hovering over the .dd_menu class, we display the .dd_link class, making all the <a> tags visible. This works perfectly in IE 7, Opera 9, and Safari 2. We sincerely hope this helps all developers out there, as it is so simple to use, and very elegant in the context of simple UI.


3 Responses  
  • reader writes:
    May 8th, 2008 at 9:54 pm

    nothing special,

    me and surely millions other web developers coding them for years by ourselves

  • John_Betong writes:
    May 9th, 2008 at 1:45 am

    I like your simple idea, tried it but came across the following bugs:

    1. CSS comments must be enclosed in /* … */ and not //

    2. There are 2 types of elements in the body of a HTML file, inline and block elements. Your block-level element cannot be inside the inline element .

  • Nitesh writes:
    May 9th, 2008 at 3:53 am

    @reader
    I’m sure if we could figure it out, it can’t be that smart anyway.

    @John_Betong
    We’ve made the code bare bones simple now.. you should not have any problems now…


Leave a Reply

»  Substance: WordPress   »  Style: Ahren Ahimsa