Reputation: 9286
Do you know what is chrome's reason for this? Is there a remedy?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body style="perspective:500px">
<div style="
width:40px;
height:40px;
background: green;
padding: 30px;
transform: rotateY(50deg);
transform-style: preserve-3d">
<div style="
transform: translateZ(60px)">
content
</div>
</div>
<hr style="margin: 40px 0">
<div style="
opacity: .5;
width:40px;
height:40px;
background: green;
padding: 30px;
transform: rotateY(50deg);
transform-style: preserve-3d">
<div style="
transform: translateZ(60px)">
content
</div>
</div>
</body>
</html>
Upvotes: 3
Views: 461
Reputation: 401
Using opacity with a value other than
1
places the element in a new stacking context.
This causes the flattening under browsers which are respecting the new specification.
We can use a wrapper element to set the opcaity
(this element can be the one with the main perspective
property as well depending on what we need):
<div style="perspective:500px">
<div style="perspective:inherit;opacity:.5">
<div style="
width:40px;
height:40px;
background: green;
padding: 30px;
transform: rotateY(50deg);
transform-style: preserve-3d
">
<div style="transform: translateZ(60px)">
content
</div>
</div>
</div>
</div>
Upvotes: 1
Reputation: 64244
I would say this is what should happen as per standards:
A value of preserve-3d for transform-style establishes a stacking context.
The following CSS property values require the user agent to create a flattened representation of the descendant elements before they can be applied, and therefore override the behavior of transform-style: preserve-3d:
overflow: any value other than ‘visible’
opacity: any value other than 1.
filter: any value other than ‘none’.
Upvotes: 0