Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Creating a CSS drop-down menu with a search box the pops down from the search icon....

Creating a CSS drop-down menu with a search box the pops down from the search icon....

Problem

I am Creating a CSS hover drop down menu. I have a Search icon that has a hover on it also. When you hover over the icon it drops down an input for a search. However when the mouse moves off the area the search box disappears. Looking to keep the box there as long as the cursor is inside the input field, or the input is focused. I may end up just doing a toggle on the search menu icon if that is the best option, but would rather have it work as previously stated, so if you clicked elsewhere on the screen it would disappear.

If you need me to post what I have just let me know, but it's basically just this with a standard pure CSS hover drop-down, this is the basic html setup:

So it works but like I stated when you move off, even with the cursor flashing it will hide again. Looking for some way to keep it active. I'm assuming I'll need some sort of JavaScript to make this work, but not sure where to start with that. This is my first post so if I a messing up some sort of protocol, I apologize.

Thanks!

Problem courtesy of: Wolf Head

Solution

you could just add and remove a class to the li using javascript something to the effect of

    $( ".search" ).onmouseenter( function() {
        $( "input" ).addClass( "seeMe" ).focus();
    });

    $( "input" ).blur( function() {
        $( this ).removeClass( "seeMe" );
    });

This makes the the input visible and gives it focus when you hover over the search li and hides when it the input loses focus

see a modified version of this on my jsFiddle

Solution courtesy of: Decker W Brower

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Creating a CSS drop-down menu with a search box the pops down from the search icon....

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×