mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
For grid items with auto preferred size, stretch/normal alignment, and no auto margins, the final size is simply the containing block size minus margin box sizes. We can compute this directly without calling `calculate_fit_content_width/height`, which triggers expensive intrinsic sizing layout passes.
34 lines
755 B
HTML
34 lines
755 B
HTML
<!DOCTYPE html>
|
|
<style>
|
|
* {
|
|
border: 1px solid black;
|
|
}
|
|
.grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
grid-template-rows: 1fr 1fr;
|
|
width: 200px;
|
|
height: 200px;
|
|
}
|
|
.item {
|
|
background: lightyellow;
|
|
}
|
|
.with-margin {
|
|
margin: 10px;
|
|
}
|
|
.with-horizontal-margin {
|
|
margin-left: 5px;
|
|
margin-right: 15px;
|
|
}
|
|
.with-vertical-margin {
|
|
margin-top: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
<div class="grid">
|
|
<div class="item">no margin</div>
|
|
<div class="item with-margin">10px margin</div>
|
|
<div class="item with-horizontal-margin">h margins</div>
|
|
<div class="item with-vertical-margin">v margins</div>
|
|
</div>
|