mjml icon indicating copy to clipboard operation
mjml copied to clipboard

Image width in % resolves to px

Open kickbk opened this issue 8 years ago • 3 comments

Go to https://mjml.io/try-it-live/SJFCVGloG in <mj-image src="http://nimus.de/share/tpl-realestate/box-top.png" width="220px" alt="" align="center" border="none"></mj-image> change width="220px" to width="100%"

Inspect element and look at the img tag. It will show:

<img alt="" height="auto" src="http://nimus.de/share/tpl-realestate/box-top.png" style="border:none;border-radius:0;display:block;font-size:13px;outline:0;text-decoration:none;width:100%;height:auto" width="100"> Here the style tag is correct, but the width shows 100 which is in px. However, the real problem is the surrounding td that has style="100px".

In your docs you do mention the values for this attribute is in px, but then again button width are also in px, but you can assign 100%.

Applying the attribute 100% to the surrounding div will result in the image stretching to 100%. Isn't that something that should be supported?

I should also mention that setting the width to 100000px could theoretically resolve the issue by stretching to image while it is contained, however, the final HTML has width=240px on the td regardless, so this is probably a bug?

kickbk avatar Apr 02 '18 20:04 kickbk

Hi,

This is not a typo in doc, mj-image supports only px width to make old desktop outlook happy cf https://github.com/mjmlio/mjml/issues/1044.

On Mon, Apr 2, 2018 at 10:54 PM, kickbk [email protected] wrote:

Go to https://mjml.io/try-it-live/SJFCVGloG in change width="220px" to width="100%"

Inspect element and look at the img tag. It will show:

Here the style tag will be correct, but the width is not. However, the real problem is the surrounding td that has style="100px".

In your docs you do mention the values for this attribute is in px, but then again button width are also in px, but you can assign 100%.

Applying the attribute 100% to the surrounding div will result in the image stretching to 100%. Isn't that something that should be supported?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mjmlio/mjml/issues/1111, or mute the thread https://github.com/notifications/unsubscribe-auth/AAizzS41-xX5F9G1GJnOorEQZK7-10nDks5tkpAjgaJpZM4TEEv3 .

-- Cordialement, Maxime BRAZEILLES

iRyusa avatar Apr 02 '18 22:04 iRyusa

@kickbk Now I'm confused. The code seems to support percentages, so I don’t know what to believe - the code or the docs???? How do I know which is correct?

Code:

static allowedAttributes = { 'alt': 'string', 'href': 'string', 'src': 'string', 'srcset': 'string', 'title': 'string', align: 'enum(left,center,right)', border: 'string', 'border-bottom': 'string', 'border-left': 'string', 'border-right': 'string', 'border-top': 'string', 'border-radius': 'unit(px,%)', 'container-background-color': 'string', padding: 'unit(px,%){1,4}', 'padding-bottom': 'unit(px,%)', 'padding-left': 'unit(px,%)', 'padding-right': 'unit(px,%)', 'padding-top': 'unit(px,%)', height: 'unit(px,%)', width: 'unit(px,%)', }

davidaddison avatar Apr 03 '18 00:04 davidaddison

This was a typo in the current code, doc always mentioned px as supported width unit as said just before... Note that allowedAttributes are still not a thing yet and will be used in 4.1

On Tue, Apr 3, 2018 at 2:09 AM, David K Addison [email protected] wrote:

@kickbk https://github.com/kickbk Now I'm confused. The code seems to support percentages, so I don’t know what to believe - the code or the docs???? How do I know which is correct?

Code:

static allowedAttributes = { 'alt': 'string', 'href': 'string', 'src': 'string', 'srcset': 'string', 'title': 'string', align: 'enum(left,center,right)', border: 'string', 'border-bottom': 'string', 'border-left': 'string', 'border-right': 'string', 'border-top': 'string', 'border-radius': 'unit(px,%)', 'container-background-color': 'string', padding: 'unit(px,%){1,4}', 'padding-bottom': 'unit(px,%)', 'padding-left': 'unit(px,%)', 'padding-right': 'unit(px,%)', 'padding-top': 'unit(px,%)', height: 'unit(px,%)', width: 'unit(px,%)', }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mjmlio/mjml/issues/1111#issuecomment-378086781, or mute the thread https://github.com/notifications/unsubscribe-auth/AAizzbFMDLhufecHszT5core64eTHl8mks5tkr25gaJpZM4TEEv3 .

-- Cordialement, Maxime BRAZEILLES

iRyusa avatar Apr 03 '18 00:04 iRyusa