dompdf - CSS max width images

3,066 views
Skip to first unread message

Bastian Sander

unread,
Jul 26, 2011, 6:24:05 AM7/26/11
to dompdf-dev
Hi,

i have an css error:

<div style="width: 300px;">
<img src="http://www.resorti.de/out/pictures/z1/140-8_z1.jpg"
style="max-width: 300px;" alt="" />
</div>

max-width has no effect on my picture. If the picture has a width of
340px it is bigger than the div.
How can i fix it?

Best Regards

BrianS

unread,
Jul 26, 2011, 10:17:41 AM7/26/11
to dompd...@googlegroups.com

This appears to be buggy. For the time being, if your actual code is similar to what you have posted you can work around the problem with something similar to the following:

<div style="width: 300px;"><div style="max-width: 300px;">
  <img src="http://www.resorti.de/out/pictures/z1/140-8_z1.jpg" style="width: 100%;" alt="" />
</div></div>

Just wrap your image tags with a div specifying the max width, then specify the image width as 100%. There are other, similar variations that would also work.

Note: this post would be more appropriate in the dompdf support group. The purpose of this group is to discuss the internals of dompdf and future development. While your issue points to a problem in the code, the overall topic is one of support. You could also post a bug report if you like, since this appears to be due to a bug.
Reply all
Reply to author
Forward
0 new messages