jQuery Bounce In Place

前端 未结 1 608
星月不相逢
星月不相逢 2021-01-20 21:16

I need my list item elements to bounce in place and not fall all over each other.

I created a JSFiddle of what I mean: http://jsfiddle.net/RGvjj/

Can someone

相关标签:
1条回答
  • 2021-01-20 22:08

    Try removing the inline display from the <li> and use float:left instead.

    Try it out: http://jsfiddle.net/RGvjj/1/

    #navigation li {
        font-size: 20px;
        margin-left: 10px;
        padding-left: 10px;
        border-left: 3px solid #1161A5;
        color: #ffffdd;
        text-decoration: none;
        float:left;
    }
    

    EDIT: To explain, I'm guessing this is happening because when you animate an element, jQuery changes the display to block. So you were ending up with a block element (the <a>) inside an inline element (the <li>) which doesn't work.

    By using float:left, the <li> retains its block display, which makes it valid for the <a> to be block.

    0 讨论(0)
提交回复
热议问题