Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-animations/inherited-animation-opacity.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<title>CSS Animations: inheriting an animated opacity</title>
<link rel="author" title="Free Debreuil" href="mailto:freedebreuil@google.com">
<link rel="match" href="/css/reference/ref-filled-green-100px-square.xht">
<script src="support/inherited-animation-reftest.js"></script>
<style>
.square, .child {
width: 100px;
height: 100px;
background: green;
}
.square {
anchor-name: --square;
}
.parent {
height: 100%;
background: black;
/* Green has channel value 128: these steps give whole-number
contributions when the two layers are blended. */
animation: anim 1s steps(128) infinite;
}
/* The popover escapes the parent's opacity and adds back exactly the green
that the black parent removes:
.square .parent .child (plus-lighter)
green channel = 128 * (1 - opacity) + 0 * opacity + 128 * opacity
= 128 - 128 * opacity + 128 * opacity
= 128
This only holds while the child's opacity matches the parent's. */
.child {
position-anchor: --square;
position-area: center;
margin: 0;
padding: 0;
border: 0;
mix-blend-mode: plus-lighter;
opacity: inherit;
}
@keyframes anim {
from { opacity: 0; }
to { opacity: 1; }
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="square">
<div class="parent">
<div class="child" popover="manual"></div>
</div>
</div>
<script>
document.querySelector('.child').showPopover();
</script>
</html>