How to remove default padding/margin from around t

2019-06-19 01:47发布

问题:

I'm having some trouble finding away to remove the padding or margin default values from around my html email in most versions of outlook. I was wondering if there is something that I can put into my HTML email to prevent the padding/margin from showing.

Thanks

回答1:

This works:

<body style="margin: 0px; padding: 0px; background-color: #252525" bgcolor="#252525">

Just note whatever you set the body background color to will bleed into the email chain if it is forwarded. I'd suggest leaving the body white and setting the color on a html container table to prevent this.



回答2:

Also if you need for your table cells to be completely flat without padding and empty make sure to add this to the table:

    <table cellpadding="0" cellspacing="0">

And in the case of the empty cells

    <td style="font-size:0px;">


回答3:

Try using the CSS reset from the HTML Boilerplate:

body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;}
.ExternalClass {width:100%;}

Or better yet, just use the Boilerplate as the starting point for your e-mails.



回答4:

You can add inline styles, that override Outlook's defaults (they have higher precedence).

Eg.

<div style="padding:0; margin:0;" class="wrapper">
  ... etc ...
</div>