Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
have the following snippet of code that goes through email into GMAIL:

<table width="800" align="center" cellspacing="0" cellpadding="0" border="0" bgcolor="" class="100p">

<div style="position: relative; left: 0; top: 0;">

<img src="background.jpg" style="position: relative; top: 0; left: 0; display:block;"/>

<a href="link.com">
<img src="mainimage.jpg" style="position: absolute; margin-left: auto; margin-right: auto; left: 0; right: 0; top: 0; bottom: 0; top: 0; bottom: 0; display:block;" />
</a>

</div>

But when shown through gmail, it simply stacks the two.
Posted
Updated 20-Sep-15 19:43pm
v2

1 solution

image mainimage has multiple redundant style definition. If you make it abssolute, margins are irrelevant. If you set top then the bottom clause takes it down to 0 distance from bottom from left and right will work same way. You do not need to define display:block because image is already block element.

if background image isonly for backgroun yo can define background as not repeating background of div at position 0,0 (which is predefined position)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900