CSS3: transform property not working as expected i

2019-01-15 21:17发布

I am trying to achieve the below thing ..And its working pretty well in firefox but the same css

Expected Result in Firefox

working in chrome is somewhat like this shown below

Screenshot in Chrome

I think -webkit-transform-origin: 50% 100%; doesnt work in chrome or its working but not as expected

Demo Jsfiddle

#flyDiv {
    width:720px;
    height:420px;
    transform-origin: 50% 100%;
    perspective: 300;
    transform: perspective(300px) rotateX(15deg);
    -webkit-transform: perspective(300px) rotateX(15deg);
}

2条回答
Animai°情兽
2楼-- · 2019-01-15 21:50

Probably I have found an error ..This is hardware issue I have checked in many computers and found that pc in which their are graphic cards present they are the one who can run them smoothly as they are hardware accelerated ..Otherwise the slantness differs bcoz its software accelerated..

just check ur pc config by chrome://gpu in address bar and u will find the diff

Following image is that in which its running fine... Hardware Accelerated PC

Following image is that in which its not running as expected... Software Accelerated PC

Anyways Thanks for your answers and comments ..One favour plz confirm me this by checking if possible ..Thanks

查看更多
Lonely孤独者°
3楼-- · 2019-01-15 21:52

you are not doing it in the right way you have to use transform-style: preserve-3d on the parent element then you can transform the child. And since you are using 3d for a better performance you will need backface-visibility: hidden;

and you ve to use -webkit-transform-origin: 50% 100%; or just user prefixfree from LEA VEROU

http://leaverou.github.io/prefixfree/

parent:

 section#transform3d{
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    transform-style: preserve-3d;       
        }

child

#flyDiv {
    width:720px;
    height:420px;
    -webkit-transform-origin: 50% 100%;
    -moz-transform-origin: 50% 100%;
    transform-origin: 50% 100%;
    -webkit-perspective: 300px;
    -moz-perspective: 300px;
    perspective: 300px;

    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    /*  -webkit-transition: -webkit-transform 10s; 
    -webkit-transform-origin: 50% 100%; */
    -webkit-transform: perspective(300px) rotateX(15deg);
    -moz-transform: perspective(300px) rotateX(15deg);
    transform: perspective(300px) rotateX(15deg);
}

demo : http://jsfiddle.net/kougiland/W9uPE/6/

read mor here : http://www.w3.org/TR/css3-transforms/

查看更多
登录 后发表回答