Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-sizing/aspect-ratio/grid-aspect-ratio-align-items-center.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
<link rel="help" href="https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/#aspect-ratio-automatic">
<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-1977" />
<meta name="assert" content="Grid has a definite block size computed using the inline size/aspect ratio and item is aligned accordingly (centered vertically).">
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht" />
<style>
.grid {
display: grid;
aspect-ratio: 1/1;
align-items: center;
background: linear-gradient(to bottom, green 0, green 25px, red 25px, red 75px, green 75px, green 100px);
}
.item {
width: 100px;
height: 50px;
background-color: green;
}
</style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="width: 100px">
<div class="grid">
<div class="item"></div>
</div>
</div>
</body>
</html>