diff --git a/Tests/LibWeb/Layout/expected/abspos-with-percentage-insets.txt b/Tests/LibWeb/Layout/expected/abspos-with-percentage-insets.txt
new file mode 100644
index 0000000000..b3b67d8d3e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/abspos-with-percentage-insets.txt
@@ -0,0 +1,14 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+ BlockContainer at (1,1) content-size 798x0 [BFC] children: not-inline
+ BlockContainer
at (10,10) content-size 500x400 positioned [BFC] children: inline
+ BlockContainer at (311,211) content-size 28.6875x17.46875 positioned [BFC] children: inline
+ line 0 width: 28.6875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 3, rect: [311,211 28.6875x17.46875]
+ "one"
+ TextNode <#text>
+ BlockContainer at (330.5625,351.53125) content-size 28.4375x17.46875 positioned [BFC] children: inline
+ line 0 width: 28.4375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 3, rect: [330.5625,351.53125 28.4375x17.46875]
+ "two"
+ TextNode <#text>
+ TextNode <#text>
diff --git a/Tests/LibWeb/Layout/input/abspos-with-percentage-insets.html b/Tests/LibWeb/Layout/input/abspos-with-percentage-insets.html
new file mode 100644
index 0000000000..00e6322b22
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/abspos-with-percentage-insets.html
@@ -0,0 +1,20 @@
+one
two
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index 54fcc69e6a..77af6ecd6d 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -1020,8 +1020,8 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
if (before_or_after_inside_layout == BeforeOrAfterInsideLayout::Before)
return;
- box_state.inset_top = top.to_px(box, width_of_containing_block);
- box_state.inset_bottom = bottom.to_px(box, width_of_containing_block);
+ box_state.inset_top = top.to_px(box, height_of_containing_block);
+ box_state.inset_bottom = bottom.to_px(box, height_of_containing_block);
box_state.margin_top = margin_top.to_px(box, width_of_containing_block);
box_state.margin_bottom = margin_bottom.to_px(box, width_of_containing_block);
box_state.padding_top = box.computed_values().padding().top().to_px(box, width_of_containing_block);