Chrome border with radius + overflow with perspective
I have a weird problem with Chrome.
If I create div
with some perspective, the border radius, overflow of the hidden and transformed div
inside the element will not respect the perspective.
http://codepen.io/cavax/pen/MwPgxz
If I remove the border radius as you can see the element has perspective.
Any idea?
<div id="prova">
<div id="rotate"></div>
</div>
<div id="prova2">
<div id="rotate2"> </div>
</div>
#prova {
width: 400px;
height: 200px;
-webkit-perspective: 400px;
perspective: 400px;
margin: 40px;
border: 1px solid #000;
overflow: hidden;
border-radius: 30px;
}
#rotate {
width: 200px;
height: 200px;
background-color: red;
-webkit-transform: rotateX(40deg);
transform: rotateX(40deg);
position: absolute;
bottom: 0px;
left: 100px;
}
#prova2 {
width: 400px;
height: 200px;
-webkit-perspective: 400px;
perspective: 400px;
margin: 40px;
border: 1px solid #000;
overflow: hidden;
}
#rotate2 {
width: 200px;
height: 200px;
background-color: red;
-webkit-transform: rotateX(40deg);
transform: rotateX(40deg);
position: absolute;
bottom: 0px;
left: 100px;
}
+3
source to share
2 answers
Try setting perspective directly on the child:
-webkit-transform: perspective(400px) rotateX(40deg) rotateY(0) translateZ(0);
So the result is:
#prova2 {
position: relative;
width: 400px;
height: 200px;
margin: 40px;
border: 1px solid #000;
overflow: hidden;
border-radius: 30px;
}
#rotate2 {
width: 200px;
height: 200px;
background-color: red;
-webkit-transform: perspective(400px) rotateX(40deg) rotateY(0) translateZ(0);
position: absolute;
bottom: 0px;
left: 100px;
}
0
source to share