HTML 电子邮件中的图像问题
我在构建 HTML 电子邮件时遇到困难。我目前已按以下顺序将整个电子邮件转换为 8 行表:
- 标头(图像)
- 日期字段
- 内容 字段内容
- 基础(圆角底部图像)
- 页脚顶部(圆角顶部图像)
- 页脚
- 页脚基础(圆角底部图像)
您可以看,其中四个字段中有一个图像。我对表格的布局非常严格,使其宽 550 像素,图像本身宽 550 像素,并且我在表格上使用边框折叠来消除字段边缘的出现。
我遇到的问题是,所有没有图像的字段都会伸出几个额外的像素,当我使用圆形底部和顶部时,这有点破坏了布局。我简直无法理解它为什么这样做。
图像是根据 标签添加的,我认为正在发生的事情是它在字段边缘和图像之间放置了一个间距,并且表格的其余部分取决于最大的宽度将其他宽度推出几个像素。我正在努力寻找解决方案,我尝试了很多不同的方法,例如在图像和表格上减去边距。有人可以为此提供任何解决方案吗?
下图展示了这种“步进”,虽然很小,但在导出到 Outlook 后,它似乎会增加一倍。图像从“Hydref 2010”行上方开始 -
更新:我使用了 cellspacing 和 cellpadding 命令并将它们减少到0 修复了浏览器中的显示,但在 Outlook 中是相同的
I'm having difficulty with building a HTML email. I currently have converted my entire email to an 8 row table in the below order:
- Header (image)
- Date Field
- Content Field
- Content Base (rounded bottom image)
- Footer top (rounded top image)
- Footer
- Footer Base (rounded bottom image)
As you can see, four of these fields have an image in them. I've been very strict with the layout of my table, making it 550px wide, the images themselves are 550px wide and I use border-collapse on the table to remove the appearence of field edges.
The problem I'm having is that all the fields without images in them stick out an extra couple of pixels, which as I'm using rounded bottoms and tops it kinda ruins the layout. I simple can't fathom why it's doing this.
The images are added as per the <img>
tag and what I THINK is happening is that it's putting a spacing between the edge of the field and the image and as the rest of the table is dependent on the width of the largest one it's pushing the others out a couple of pixels. I am struggling to find a solution to this, I've tried lots of different things such as minus margins on the images and tables. Can anybody offer any solutions to this?
The image below demonstrates this "stepping" and although minor, upon exporting to outlook it appears to double. The image starts above the line "Hydref 2010" -
UPDATE: I used the cellspacing and cellpadding commands and reduced them to 0 which fixed the display in a browser, but in Outlook, it's the same
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTML 电子邮件总是有点“fuuuuuuuuuuuuuuuuuuuuuuuu”,让我感到泄气。
您已经采取了正确的方法来使用表格,并且您遇到的问题是我以前见过的问题,但我一生都不记得我是如何解决它的。
您是否尝试过将列压缩为一行标记:
IE 和 Word中的
空白对于渲染空格来说非常糟糕。
如果失败,您总是可以拆分列,这样标题两侧就有一个间隔符,主图像上有一个列跨度?
HTML Emails are always a bit "fuuuuuuuuuuuuuuuuuuuuuuuu", and leave me feeling deflated.
You have taken the right approach to use tables, and the problem you are having is one I have seen before, but for the life of my I can't remember how I fixed it.
Have you tried condensing your columns into one row of markup:
into
IE and word are terrible for rending whitespace.
If that fails, you could always split your columns, so you have a spacer either side of the title and a col-span on the main images?