Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8">
<link rel="match" href="grid-items-calc-paddings-001-ref.html">
<meta name="assert" content="calc() paddings mixing a length and a percentage resolve the percentage against the inline size of the grid area, not the grid container.">
<html>
<head>
<style>
.grid {
display: grid;
justify-items: normal;
width: 300px;
height: 300px;
grid-template-columns: 150px 150px;
grid-template-rows: 150px 150px;
background-color: green;
}
/* Verify calc() padding mixing a fixed length and a percentage resolves the
percentage against the 150px grid area inline size (2% == 3px), positioning
content at (paddingLeft, paddingTop). */
.topLeft {
grid-row: 1 / 2;
grid-column: 1 / 2;
padding: calc(2px + 2%) calc(2px + 4%) calc(2px + 6%) calc(2px + 8%);
background-color: blue;
}
.topRight {
grid-row: 1 / 2;
grid-column: 2 / 3;
padding: calc(10px + 2%);
background-color: blue;
}
.bottomLeft {
grid-row: 2 / 3;
grid-column: 1 / 2;
padding: calc(4px + 10%) calc(4px + 4%);
background-color: blue;
}
.bottomRight {
grid-row: 2 / 3;
grid-column: 2 / 3;
padding: calc(6px + 6%);
background-color: blue;
}
.topLeftContent {
width: 20px;
height: 20px;
background-color: purple;
}
.topRightContent {
width: 20px;
height: 40px;
background-color: purple;
}
.bottomLeftContent {
width: 40px;
height: 20px;
background-color: purple;
}
.bottomRightContent {
width: 40px;
height: 40px;
background-color: purple;
}
</style>
</head>
<body>
<div class="grid">
<div class="topLeft"><div class="topLeftContent"></div></div>
<div class="topRight"><div class="topRightContent"></div></div>
<div class="bottomLeft"><div class="bottomLeftContent"></div></div>
<div class="bottomRight"><div class="bottomRightContent"></div></div>
</div>
</body>
</html>