Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-grid/alignment/grid-alignment-implies-size-change-044.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="assert" content="Changing the grid items' own justify-self value from 'stretch' to 'center' updates both the width and the position of non-replaced grid items.">
<style>
.grid {
position: relative;
display: grid;
grid-template-rows: 100px 100px;
grid-template-columns: 150px;
width: 150px;
}
.item {
justify-self: stretch;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="support/style-change.js"></script>
<script>
setup({ explicit_done: true });
function runTest() {
evaluateStyleChangeMultiple("before", {
item1: { "data-expected-width": 150, "data-offset-x": 0 },
item2: { "data-expected-width": 150, "data-offset-x": 0 }
});
item1.style.justifySelf = "center";
item2.style.justifySelf = "center";
evaluateStyleChangeMultiple("after", {
item1: { "data-expected-width": 50, "data-offset-x": 50 },
item2: { "data-expected-width": 100, "data-offset-x": 25 }
});
done();
}
</script>
<body onload="runTest()">
<div class="grid" id="grid">
<div id="item1" class="item" style="height: 50px; grid-area: 1 / 1;">
<div style="width: 50px;"></div>
</div>
<div id="item2" class="item" style="height: 50px; grid-area: 2 / 1;">
<div style="width: 100px;"></div>
</div>
</div>
</body>