css3 - CSS 3d transform perspective grid -


trying create block grid 3d transformed @ angle, when hover 1 of elements rotates in facing towards user. below see not-very-well working example (chrome - work safari too?).

so have couple of problems think can notice them too, hope solvable @ all;

  • rotating blocks towards user doesnt work well. perspective seems wrong: on last rows looks going different angle. , need scale(1,1.9) shouldn't necessary think, else small height.
  • the perspective changes drag screen smaller size...
  • finally animation (in chrome) doesn't go fluently. does, on occasions block first stretches , rotates @ once

how solve this? or did build before?

you can see mean here on jsfiddle (make run-screen wide)

css:

body{             -webkit-perspective: 1000;             background:black;             -webkit-background-size: cover;             -moz-background-size: cover;             -o-background-size: cover;             background-size: cover;         }         #grid{             margin:auto;             width:840px;             -webkit-transform: rotate3d(1,0,0, 70deg);             margin-top:200px;         }         #grid>div{             -webkit-perspective: 600;             -moz-perspective: 600;             perspective: 600;             color:white;             font-family:arial;             font-size:70px;             line-height:140px;             height:140px;             width:140px;             float:left;             text-align:center;             cursor:pointer;             position:relative;         }         #grid div:hover{             z-index:500;         }         #grid>div:hover div{             -webkit-transform: rotate3d(1,0,0, -39deg) scale(1,1.9);             -moz-transform: rotate3d(1,0,0, -39deg) scale(1,1.9);             transform: rotate3d(1,0,0, -39deg) scale(1,1.9);         }         #grid>div>div{             -webkit-transform-origin:50% 100%;             width:100%;             height:100%;             -webkit-transition:-webkit-transform ease 0.5s;             -moz-transition:-moz-transform ease 0.5s;             transition:transform ease 0.5s;         }         #grid>div:nth-child(4n)>div{background:red;}         #grid>div:nth-child(4n+1)>div{background:orange;}         #grid>div:nth-child(4n+2)>div{background:blue;}         #grid>div:nth-child(4n+3)>div{background:green;}          #grid>div:nth-child(6n+1){-webkit-perspective-origin: 300% 100%;-moz-perspective-origin: 300% 100%;}         #grid>div:nth-child(6n+2){-webkit-perspective-origin: 200% 100%;-moz-perspective-origin: 200% 100%;}         #grid>div:nth-child(6n+3){-webkit-perspective-origin: 100% 100%;-moz-perspective-origin: 100% 100%;}         #grid>div:nth-child(6n+4){-webkit-perspective-origin: 0% 100%;-moz-perspective-origin: 0% 100%;}         #grid>div:nth-child(6n+5){-webkit-perspective-origin: -100% 100%;-moz-perspective-origin: -100% 100%;}         #grid>div:nth-child(6n+6){-webkit-perspective-origin: -200% 100%;-moz-perspective-origin: -200% 100%;} 

html:

<div id="grid"> <div><div>hee</div></div> <div><div>wat</div></div> <div><div>is</div></div> <div><div>dit</div></div> <div><div>hee</div></div> <div><div>wat</div></div> <div><div>is</div></div> <div><div>dit</div></div> <div><div>hee</div></div> <div><div>wat</div></div> <div><div>is</div></div> <div><div>dit</div></div> <div><div>hee</div></div> <div><div>wat</div></div> <div><div>is</div></div> <div><div>dit</div></div> <div><div>hee</div></div> <div><div>wat</div></div> <div><div>is</div></div> <div><div>dit</div></div> <div><div>hee</div></div> <div><div>wat</div></div> <div><div>is</div></div> <div><div>dit</div></div> </div>   

about problems:

  1. the perspective seems wrong. yes, because is. need specify "preserve-3d". if not, grand-child rendered on child, , 1 on base element. bad news property doesn't work in i.e.; if set fix in browser except i.e.; also, since i.e. using unprefixed syntax, make code not future proof. demonstrative purposes, that:

    #grid{     margin:auto;     width:840px;     -webkit-transform: rotate3d(1,0,0, 70deg);     -webkit-transform-style: preserve-3d;      margin-top:200px; } #grid>div{     -webkit-perspective: 600;     -moz-perspective: 600;     perspective: 600;     -webkit-transform-style: preserve-3d;     color:white;     font-family:arial;     font-size:70px;     line-height:140px;     height:140px;     width:140px;     float:left;     text-align:center;     cursor:pointer;     position:relative; } 

(you see div grows excesively; leave demo purposes)

  1. the perspective changes in smaller sizes. that's because don't st perspective origin in body. if set

    body { -webkit-perspective: 1000; -webkit-perspective-origin: 420px 0px;
    background: black; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; }

that fix

about animation behaving odd; haven't been unable reproduce it.

updated demo


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -