21
Use transform: rotate
the child elements, and perspective
, in the parent element.
.a{
perspective:1000px;
text-align:center;
}
.b{
transform:rotateX(-60deg);
width:100px;
background:gold;
height:100px;
}
.c{
transform:rotateX(30deg);
width:100px;
background:tomato;
height:100px;
}
.d{
transform:rotateY(30deg);
width:100px;
background:lightgreen;
height:100px;
}
<div class="a">
<div class="b">B</div>
<div class="c">C</div>
<div class="d">D</div>
</div>
TL;DR
The estate perspective
affects only the child elements from which this property was defined, but does not affect itself.
How the property works perspective
?
This property allows you to change the perspective in which the 3D elements are seen. The perspective property determines the distance between the plane Z
and the user in order to give the 3D element some perspective.
The intensity of the effect is determined by the value of perspective
. The lower the value, the closer you start from plane Z. The higher the value, the more subtle the effect.
When defining the property perspective
in an element, it is the child elements that receive the perspective in which it is seen, not the element itself.
Note: Perspective property affects only elements transformed in 3D!
References (where I did a half-ass translation):
http://www.w3schools.com/cssref/trycss3_perspective_inuse.htm
https://developer.mozilla.org/en-US/docs/Web/CSS/perspective
You will use the
rotateX
orrotateY
and, in the parent element, will set the perspective.– Wallace Maxters
do it using border and skew
– Gabriel Rodrigues
Surely, that question deserves a favorite little star ;)
– Wallace Maxters