html - CSS 3D transform appears flat ( orthographic? ) -
on hover button flips fails show perspective. it's flat orthographic view of animation. using perspective property wrong?
@import 'https://necolas.github.io/normalize.css/latest/normalize.css'; /* //////////////////////////////// initial //////////////////////////////// */ html, body{ height:100% } body{ background:#eee } #btn { display:block; width:100px; height:100px; margin:0 auto; position:relative; transform:translatey(-50%); top:50%; background:#333; color:#eee; border:0; outline:0; text-transform:uppercase } /* //////////////////////////////// _persp_ //////////////////////////////// */ #btn{ perspective:1000px } #btn:hover { transform:rotatex(180deg); transform-style:preserve-3d } /* //////////////////////////////// _trans_ //////////////////////////////// */ #btn{ transition-property: transform; transition-duration:1s }
<!doctype html> <html lang="en"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"> <link rel="stylesheet" href="base.css"> <title>web | animation</title> </head> <body> <button id="btn">button</button> <!-- ------------------------------ comment ------------------------------- --> </body> </html>
ok first need activate hardware acceleration in browser. second use browser specific prefixes :
-webkit-transform: perspective(600px) rotatey(-180deg); -moz-transform: perspective(600px) rotatey(-180deg);
try structure :
<div id="parent"> <button id="button">button</button> </div>
css:
#parent { position: relative; margin: 10px auto; width: 450px; height: 281px; z-index: 1; } #button { width: 100%; height: 100%; -moz-transform-style: preserve-3d; -moz-transition: 1.0s linear; -webkit-transform-style: preserve-3d; -webkit-transition: 1.0s linear; } #parent:hover #button { -webkit-transform: perspective(600px) rotatey(-180deg); -moz-transform: perspective(600px) rotatey(-180deg); }
Comments
Post a Comment