开发者

jQuery Bounce In Place

开发者 https://www.devze.com 2023-01-11 03:58 出处:网络
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/

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 advise me as to why the elements are doing that and what I need to do to fix that?


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

精彩评论

暂无评论...
验证码 换一张
取 消