fixed element with wrong position after animation CSS

一个人想着一个人 提交于 2019-12-08 13:02:29

问题


Here I created jsFiddle which kind of replicates my problem

After animation (clicking on MOVE twice), fixed column comes back with wrong position.

is it possible to animate my this without using left or right for fixed positioned element?


回答1:


Updated jsfiddle http://jsfiddle.net/z8fBD/7/

Trick is to add reset translate on #body

#body {
    position:absolute;
    left: 0;
    top:0;
    width: 200px;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    transition: all 0.5s ease;
    -webkit-transform: translate(0%,0px);
    -moz-transform: translate(0%,0px);
    -ms-transform: translate(0%,0px);
    -o-transform: translate(0%,0px);
    transform: translate(0%,0px);
}



回答2:


You have to add margin:0px and padding:0px to your <body> because position:fixedlead element attop` without considering padding and margin with document.

Please check here JsFiddle Demo




回答3:


Remove "position: fixed;" from the #fixed style and it works fine...



来源:https://stackoverflow.com/questions/19873730/fixed-element-with-wrong-position-after-animation-css

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