用li和jquery导航无法正常工作

时间:2012-05-21 02:04:43

标签: jquery html css

我有以下代码:

HTML

<ul id="navigation">
<li class="quickHelp"><a href="" title="Ayuda Rápida"></a>
    <div>
        Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer. Donec ipsum. Proin imperdiet est. Phasellus dapibus semper urna. Pellentesque ornare, orci in consectetuer hendrerit, urna elit eleifend nunc, ut consectetuer nisl felis ac diam. Etiam non felis. Donec ut ante. In id eros. Suspendisse lacus turpis, cursus egestas at sem. Mauris quam enim, molestie in, rhoncus ut, lobortis a, est.
    </div>
</li>
</ul>

CSS

ul#navigation {
    position: fixed;
    margin: 0px;
    padding: 0px;
    top: 10px;
    left: 0px;
    list-style: none;
    z-index:9999;
}
ul#navigation li {
    width: 100px;
}
ul#navigation li a {
    display: block;
    margin-left: -2px;
    width: 300px;
    height: 350px;    
    background-color:#CCC;
    background-repeat:no-repeat;
    background-position:center center;
    border:1px solid #AFAFAF;
    -moz-border-radius:0px 10px 10px 0px;
    -webkit-border-bottom-right-radius: 10px;
    -webkit-border-top-right-radius: 10px;
    -khtml-border-bottom-right-radius: 10px;
    -khtml-border-top-right-radius: 10px;
    /*-moz-box-shadow: 0px 4px 3px #000;
    -webkit-box-shadow: 0px 4px 3px #000;    
    opacity: 0.6;*/
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=60);
}
ul#navigation .quickHelp a{
    background-image: url(../Content/images/info/leftBanner.png);
    background-position: right;
}

ul#navigation div{
    position: absolute;
}​

JS

$('#navigation a').stop().animate({ 'marginLeft': '-275px' }, 1000);

$('#navigation > li').hover(
    function () {
        $('a', $(this)).stop().animate({ 'marginLeft': '-2px' }, 200);
    },
    function () {
        $('a', $(this)).stop().animate({ 'marginLeft': '-275px' }, 200);
    }
);

我想要实现的是,我希望<div>的内容显示在<li>内而不是......

Here就是一个现实例子......

提前致谢!

1 个答案:

答案 0 :(得分:1)

您不需要div,并且需要将文本放在锚a内,因为这就是您用作幻灯片的内容。

请参阅updated JsFiddle