CSS “顶部”和“左侧”属性的 CSS3 过渡不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8109109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS3 transition for "top" and "left" properties not working
提问by user701510
I have a list with one item on the list transitioning to the northeast when I hover over it. Using margin-top
and margin-left
property transitions worked but the item being hovered over kept pushing other elements so I added position:relative
and tried using top
and left
transition properties but it didn't seem to be working.
我有一个列表,当我将鼠标悬停在它上面时,列表中的一个项目会过渡到东北。使用margin-top
和margin-left
属性转换有效,但悬停在上面的项目不断推动其他元素,所以我添加position:relative
并尝试使用top
和left
转换属性,但它似乎没有工作。
Here is the jsfiddle:
这是jsfiddle:
采纳答案by uadrive
Have you tried setting the parent of your list. I know sometimes relative has issue unless the underlying item is also relative or absolute. Just a thought.
您是否尝试过设置列表的父级。我知道有时相对会有问题,除非基础项目也是相对或绝对的。只是一个想法。
回答by COBOLdinosaur
Use position:absolute and it will take it out of the normal document flow. You could also give it z-index:5 to make sure it floats over other elements.
使用 position:absolute 会脱离正常的文档流。你也可以给它 z-index:5 以确保它浮动在其他元素上。