Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't make translate3d Z property to work

I am traying to use:

 -webkit-transform: translate3d(0,500px,300px);

X and Y properties working just fine, but Z (300px),just won't work. Here is the jfiddle. What am I doing wrong? I tried both Chrome 24 and Canary 25 Thanks for your support...

like image 929
hjuster Avatar asked Jan 26 '13 13:01

hjuster


People also ask

How do you translate Z in CSS?

CSS | translateZ() function. The translateZ() function is an inbuilt function which is used to reposition the element along the z-axis in 3D space. Parameters: This function accepts single parameter t which holds the length of translation corresponding to z-axis.

How do I use translation3d?

CSS | translate3d() FunctionThis parameter holds the value in form of number or percentage. ty: This parameter holds the length of translation corresponding to y-axis. This parameter holds the value in form of number or percentage. tz: This parameter holds the length of translation corresponding to z-axis.

What values can the transform property take?

The transform property may be specified as either the keyword value none or as one or more <transform-function> values.

What is transform translate() in CSS?

The translate() CSS function repositions an element in the horizontal and/or vertical directions. Its result is a <transform-function> data type.


1 Answers

According to WebKit Blog ,

translate3d(x, y, z), translateZ(z) Move the element in x, y and z, and just move the element in z. Positive z is towards the viewer. Unlike x and y, the z value cannot be a percentage.

You'd need anther element to get the effect. I added a few to your code.

HTML

<div class="coin1">
    <div class="coin2"></div>
</div>

CSS

.coin1{
    position:absolute;
    top:50px;
    left:50px;
    width:80px;
    height:40px;
    background:#fc0;
    -webkit-transform: rotate3d(1,0,0,-55deg) rotate3d(0,0,1,30deg);
    -webkit-transform-style: preserve-3d;
}

.coin1 .coin2
{
    background:#444;
    width:inherit;
    height:inherit;
    -webkit-transform: translate3d(0,0,150px);
}

It seems working and JSFiddle is here.

Frankly, I don't have much knowledge about the translate3d and but recently found some links about CSS3 Transformation while learning CSS3.

  • CSS3 Transformation
  • Hardware-Accelerated CSS
  • CSS3 3D Transform
  • CSS3 Translate3d -Z Value
like image 61
Ye Lin Aung Avatar answered Oct 15 '22 21:10

Ye Lin Aung