简体   繁体   中英

Div padding/background-color not working in outlook

<div align="center" style="background:#bfcfe4;"><font face="Arial, Helvetica, sans-serif" style="font-size: 13px;"><br /><div style="width:666px; background-color:#ffffff; margin:10px auto 40px; padding:10px 34px 34px;"><table width="670" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color:#000000;"><tr><td>some html here...</td></tr></table></div></div>

在此处输入图片说明

The top picture is from browser(s) and the bottom one is from outlook. As you can see that the padding in the bottom one is not working. I am not sure why is this happening, please help.

There are a few wacky things going on in your code. It's probably one of these 3 issues:

  • the margin (you should avoid margin in email as there is spotty support)
  • the missing 4th value to your padding (Outlook may be treating it as 0, causing no padding on the left side)
  • your widths don't add up. The div should be the width of your table + left padding + right padding.

You would also be better served to use nested tables than the div as they cause a lot less headaches.

现在习惯于此仅用于前景

<div style="padding-left:34px;padding-right:34px;padding-top:10px;" bgcolor="#bfcfe4">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM