Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Grid Lanes: Dense Packing with Negative Margins</title>
<link rel="help" href="https://drafts.csswg.org/css-grid-3/">
<link rel="match" href="column-negative-margin-004-ref.html">
<link rel="author" title="Celeste Pan" href="mailto:celestepan@microsoft.com">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<style>
.grid-lanes {
display: grid-lanes;
grid-template-columns: repeat(4, 100px);
grid-auto-flow: dense;
grid-lanes-pack: dense;
gap: 10px;
margin-top: 100px;
border: solid 2px blue;
width: min-content;
font-family: Ahem;
font-size: 10px;
}
</style>
</head>
<body>
<p>Test that negative margins affect the item's size and contribution to dense-packing.</p>
<div class="grid-lanes">
<div style="background-color: lightcoral; height: 100px;">block</div>
<div style="grid-column: span 4; background-color: lightcoral;">spanner</div>
<!-- Item 1 should not contribute any size at all to the track opening in Track 2. -->
<div style="background-color: lightgreen; height: 30px; margin-top: -45px;">Item 1</div>
<div style="background-color: lightblue; height: 100px;">Item 2</div>
<!-- Item 3 should add a stacking axis gap contribution to the top of Track 3.
An item must be < 90px to fit into the track opening now. -->
<div style="background-color: lightgreen; height: 30px; margin-top: -30px;">Item 3</div>
<div style="background-color: lightblue; height: 90px; grid-column: 3;">Item 4</div>
<!-- Item 5 should not contribute any size at all to the track opening in Track 2. -->
<div style="background-color: lightgreen; height: 30px; margin-top: -40px;">Item 5</div>
<div style="background-color: lightblue; height: 100px;">Item 6</div>
<div style="background-color: lightcoral; height: 100px;">block</div>
<div style="grid-column: span 4; background-color: lightcoral;">spanner</div>
<!-- Item 7 should not affect the size of the track opening in Track 2 -- Item 8 & 9 will cover Item 7. -->
<div style="background-color: lightgreen; height: 30px; margin-bottom: -45px;">Item 7</div>
<div style="background-color: lightblue; height: 15px;">Item 8</div>
<!-- Item 9's margin-bottom should still have an effect on the placement of the item below it. -->
<div style="background-color: lightblue; grid-column: 2; height: 40px; margin-bottom: -20px;">Item 9</div>
<div style="background-color: steelblue; grid-column: 2; height: 45px;">Item 10</div>
</div>
</body>
</html>