at (425,8) content-size 50x50 flex-item [BFC] children: inline
+ line 0 width: 6.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 1, rect: [425,8 6.34375x17.46875]
+ "1"
+ TextNode <#text>
+ BlockContainer
at (375,8) content-size 50x50 flex-item [BFC] children: inline
+ line 0 width: 8.8125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 1, rect: [375,8 8.8125x17.46875]
+ "2"
+ TextNode <#text>
+ BlockContainer
at (325,8) content-size 50x50 flex-item [BFC] children: inline
+ line 0 width: 9.09375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 1, rect: [325,8 9.09375x17.46875]
+ "3"
+ TextNode <#text>
diff --git a/Tests/LibWeb/Layout/input/flex/flex-row-reverse-with-centered-content.html b/Tests/LibWeb/Layout/input/flex/flex-row-reverse-with-centered-content.html
new file mode 100644
index 0000000000..01b19d91c9
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/flex/flex-row-reverse-with-centered-content.html
@@ -0,0 +1,11 @@
+
1
2
3
\ No newline at end of file
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 5c9f157948..96c64f2d1f 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -1268,6 +1268,9 @@ void FlexFormattingContext::distribute_any_remaining_free_space()
break;
case CSS::JustifyContent::Center:
initial_offset = (inner_main_size(flex_container()) - used_main_space) / 2.0f;
+ if (is_direction_reverse()) {
+ initial_offset = inner_main_size(flex_container()) - initial_offset;
+ }
break;
case CSS::JustifyContent::SpaceBetween:
space_between_items = flex_line.remaining_free_space / (number_of_items - 1);