From 1e897b58ef26bca372777f431c9a837fb27085fd Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 30 Dec 2024 19:32:42 +0100 Subject: layout: fix position: relative for right, bottom They are relative to the box's actual position, not that of the parent: > For relatively positioned boxes, the offset is with respect to the > bottom edge of the box itself. --- src/css/layout.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/css') diff --git a/src/css/layout.nim b/src/css/layout.nim index 66839327..6869ae21 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -1763,13 +1763,11 @@ proc positionRelative(lctx: LayoutContext; parent, box: BlockBox) = if box.computed{"left"}.u != clAuto: box.state.offset.x += positioned.left elif box.computed{"right"}.u != clAuto: - box.state.offset.x += parent.state.size.w - box.state.size.w - - positioned.right + box.state.offset.x -= positioned.right if box.computed{"top"}.u != clAuto: box.state.offset.y += positioned.top elif box.computed{"bottom"}.u != clAuto: - box.state.offset.y += parent.state.size.h - box.state.size.h - - positioned.bottom + box.state.offset.y -= positioned.bottom # Note: caption is not included here const RowGroupBox = { -- cgit