From e20616575d18ad135638a23ef0d8ed4ec0776c97 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 22 Feb 2018 18:28:38 +0100 Subject: [PATCH] Fix replaced_max_content_width Related to #576. --- weasyprint/layout/preferred.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weasyprint/layout/preferred.py b/weasyprint/layout/preferred.py index eb11cca9..4cfe23e3 100644 --- a/weasyprint/layout/preferred.py +++ b/weasyprint/layout/preferred.py @@ -640,6 +640,9 @@ def replaced_max_content_width(box, outer=True): width, _ = default_image_sizing( iwidth, iheight, image.intrinsic_ratio, 'auto', height, default_width=300, default_height=150) + elif box.style['width'].unit == '%': + # See https://drafts.csswg.org/css-sizing/#intrinsic-contribution + width = 0 else: assert width.unit == 'px' width = width.value