mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Respect margin boxes when center-aligning flex items
This commit is contained in:
parent
495b3169e0
commit
ce93088a81
|
|
@ -1476,7 +1476,9 @@ void FlexFormattingContext::align_all_flex_items_along_the_cross_axis()
|
|||
item.cross_offset = half_line_size - item.cross_size.value() - item.margins.cross_after - item.borders.cross_after - item.padding.cross_after;
|
||||
break;
|
||||
case CSS::AlignItems::Center:
|
||||
item.cross_offset = -(item.cross_size.value() / 2);
|
||||
// https://drafts.csswg.org/css-flexbox/#align-items-property
|
||||
// The flex item’s margin box is centered in the cross axis within the line
|
||||
item.cross_offset = (-item.cross_size.value() + item.margins.cross_before + item.borders.cross_before + item.padding.cross_before - item.margins.cross_after - item.borders.cross_after - item.padding.cross_after) / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
11
Tests/LibWeb/Layout/expected/flex/align-center-margin.txt
Normal file
11
Tests/LibWeb/Layout/expected/flex/align-center-margin.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x216 [BFC] children: not-inline
|
||||
Box <body> at (8,8) content-size 784x200 flex-container(row) [FFC] children: not-inline
|
||||
BlockContainer <div> at (8,58) content-size 100x100 flex-item [BFC] children: not-inline
|
||||
BlockContainer <span> at (108,108) content-size 100x100 flex-item [BFC] children: not-inline
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x216]
|
||||
PaintableBox (Box<BODY>) [8,8 784x200]
|
||||
PaintableWithLines (BlockContainer<DIV>) [8,58 100x100]
|
||||
PaintableWithLines (BlockContainer<SPAN>) [108,108 100x100]
|
||||
17
Tests/LibWeb/Layout/input/flex/align-center-margin.html
Normal file
17
Tests/LibWeb/Layout/input/flex/align-center-margin.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html><style>
|
||||
body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
div {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: red;
|
||||
}
|
||||
span {
|
||||
margin-top: 100px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: blue;
|
||||
}
|
||||
</style><body><div></div><span></span>
|
||||
Loading…
Reference in New Issue
Block a user