jQuery Bounce In Place

≡放荡痞女 提交于 2019-12-09 03:43:36

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3451952/jquery-bounce-in-place

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!