How to make an image responsive in HTML email regardless of image size

前端 未结 3 1754
南方客
南方客 2020-12-28 08:54

I am creating an email template where my container has a max-width: 600px. I want to be able to upload images that are in excess of 800px wide, and the images to scale down

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 09:23

    Yes and no. Outlook tends to force the image to its actual size, regardless of your CSS and HTML sizings. So using images that are bigger than what you want to be displayed on your desktop version is likely to break on Outlook.

    Your best bet for responsive images would be to have the images as 100% width inside a table that has max-width set. Then around this table, make conditional code for MSO that contains a set width table at the max-width size.

    Example below:

    
      

    There will still be some quirks with using max-width as not all clients support it. I would view CSS compatability and make little tweaks as needed on top of the above to ensure it fits. Then test and test some more.

提交回复
热议问题