Open ggrossetie opened 4 years ago
Using a percentage image width is highly discouraged and technically not compliant. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#attr-width. So unexpected things are actually expected.
This is related to #1894.
Using a percentage image width is highly discouraged and technically not compliant. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#attr-width. So unexpected things are actually expected.
Ok thanks for clarifying!
This is related to #1894.
On Chrome I have the exact same behavior using an inline style as suggested in https://github.com/asciidoctor/asciidoctor/issues/1894#issuecomment-253917919: We could do the same for HTML by introducing the html5width (or just htmlwidth) attribute. That would be translated to the inline CSS width property on the image. wdyt?
Am I missing something? I guess we could compute the image width/height in pixels in the converter but that would require to get the image dimensions...
What I'm suggesting in #1894 is to pass the value to the CSS width property, which does accept other units (and will likely work as expected). You could try it by tweaking the output and see what happens.
IIUC in HTML5 <img>
width and height are supposed to be the actual image size so the browser can allocate space in the layout without having to wait to download the image.
CSS can still have percentage widths that work as specified (% of parent), but that means generating CSS tied to individual images.
Consider the following AsciiDoc document:
usage-share.png has a width of 640px.
I would expect the content box of the image to have a width of 320px (ie. 50% of 640px) but instead the content box is still 640px:
Image has a width of 320px (50%)
content box has a width of 640px (100%)
image block has a width of 640px (100%)
Is it intended? Is it a CSS limitation? For reference, if I'm not using "float", then the image width is 485px (50% of the page width). Semantically, "width=50%" means 50% of the image width (not 50% of the width available). So I would expect the image to have a 320px width.
Original issue: https://github.com/Mogztter/asciidoctor-pdf.js/issues/143