tags:

views:

511

answers:

2

Hi, I have a link which once hovered over a box below slides down, once hover is removed it slides back up. I have it working almost to how I want, although in IE8 (Havent tested in other IE yet) the text in the box which slides down is not centerd. In firefox, when it slides down the corners are not smooth, but they are in IE.

Live test here

Code:

<script type="text/javascript">

 $(document).ready(function() 
 {
    $('#nav_top').corners('5px');
        $('#nav_bottom').hide();
        $('#nav_bottom').corners();

    $('#link').hover(function() 
        {
            $('#nav_top').corners('10px top');
            $('#nav_bottom').stop(true, true).slideDown();                  
            $('#nav_bottom').slideDown("slow");



        },

        function ()
        {
        $('#nav_bottom').slideUp("fast");

    }

        );          


}); 

</script>   


<div id="nav_top">

<a href="javascript:void(0);" id="link">Hover</a>

<div id="nav_bottom">

<br />Stuff 

</div>

</div>

</div>

Any advice, also is it better to use .hover or .mouseEnter / mouseLeave?

Thanks

Css:

nav_top
{
background-color: #084B8A;
text-align: center;
margin-left: 150px; 
margin-top: 15px;
width: 100px;
padding: 20px;  
font-size: 20px;
}

#nav_top a
{
text-decoration: none;
color: #ffffff;
}


#nav_bottom
{
text-align: center;
background-color: #084B8A;  
z-index: 1;
padding: 30px;  

}
A: 

I would bet the centered text issue is not a jquery issue but rather a css issue. Have you tried using the style="text-align: center;" like so

mysql_quest
Yeh I have that in my css - Added css code above cheers
Elliott
A: 

try this!

$("#link").hover(
    function() { 
   $('#nav_top').corners('10px top');
    $(this).next().slideDown("slow");
    },
    function() {  
    $(this).next().slideUp("fast");
  }
);

CSS

in anycase you need to set the position:
//container
#nav_top {
  position: relative;
}
//the inner element
#nav_bottom {
  position: absolute;
 
}
aSeptik
Am not declaring it twice? I was clearing the queue of any slideDowns so it doesnt mess up when you hover over it 100's of times.
Elliott
you can try using $(this).next().slideDown(1000); numbers instead of fast or slow! in anycase i think is better to use animate() Let me know
aSeptik
I tried your code and it didnt make any difference, I am aware of using numbers I just prefer to use fast/slow :). Thanks
Elliott
see the updates!
aSeptik
ah! and this would be a sliding pannel OR a menu!?
aSeptik
Thanks that kinda works but messes up in IE, I think its something to do with my width/height.
Elliott
in IE the important thing is to declare the Height and width yes! you need to do it with your #nav_top. for this reason i have asked you what kind of thing are you doing!! ;-)
aSeptik
The top part is the menu, the bottom is just additional info about the menu.
Elliott