Chrome bug border-radius+overflow with perspective

466 Views Asked by At

I'm having a strange problem with Chrome.

If I create a div with some perspective, border radius, overflow hidden and a transformed div inside the element wont respect de 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;
}
2

There are 2 best solutions below

0
On

Actually overflow:hidden to hide perspective area. So it is not display.

When you removed overflow:hidden; it will be working properly

Thanks

0
On

Try to set perspective directly in child:

-webkit-transform: perspective(400px) rotateX(40deg) rotateY(0) translateZ(0);

So 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;
}