javascript - Showing underlying Link on mouseOver -


i searched bit , unable find answer suited question. albeit using z-index , absolute positioning seem work, doesn't.

what trying have menu slides left on mouseover, displaying underlying link... i've been trying work without success. tried using absolute positioning on cloned element place behind parent, didn't work. used z-index make sure clone behind parent well.

my code follows:

<ul id="nav">    <li><a href="#" data-slide-text="slide-aaa">aaa</a></li>    <li><a href="#" data-slide-text="slide-bbb">bbb</a></li </ul>    (function ($) { $.fn.doit = function () {           this.find('li')         .css({             overflow : 'auto'         })                    .hover(             function(){                 $(this).find('a:first').animate({                     marginleft : "-150px"                 }, 'fast')         },             function(){                 $(this).find('a:first').animate({                     marginleft : "0px"                 }, 'fast')                             })      this.find('a')         .each(function(){            var slidetext = $(this).data('slidetext');            $(this)                 .clone()                 .text(slidetext)                 .appendto($(this).parent())                 .addclass('slideclass')         }); }; })(jquery); 

the css used is:

#nav li{    list-style: none;    float: left;    width: 150px;    height: 20px;    color: #cccccc;    height: 60px;    line-height: 30px;    text-align: center; }  #nav a{    position: relative;    display: block;    width: 150px;    z-index: 1;    background: #777777; }  .slideclass{    position: absolute;    left: 0;    top: 0;    display: block;    background: #000000;    color: #6699dd;    z-index: 3; } 

you can see live example at: jquery slide menu

i have modified css in working fiddle

the key changes i've made css:

#nav li {   display: inline-block;   overflow: hidden !important;   white-space: nowrap; } 

i removed height: declarations #nav li , position: related declarations .slideclass. finally, i've changed #nav a display: inline-block; well.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -