How can I position an element in any email template. In the design that I have to place an image over the other, which can be possible only with positioning it absolute or giving it a margin. As far as I know google doesn't support margin and positioning styling for any element. Is there any other way to solving this issue..
At present it looks something like this
Expected output
The most used email clients don't support position
css property. Reference.
I can suggest two options to you.
Put the bigger image as a background of the parent element and put another image in a child <img>
tag. And play around with the width
, height
& float
properties of parent and child elements.
<div style="background: url(...);">
<img src="..."/>
</div>
For cover photo use background-image
and for user photo use img
, then place img inside cover photo and give it an upper offset with additional div
above img
.
working example http://codepen.io/anon/pen/oXZXmp
css
.container {
background: red;
margin: auto;
width: 600px;
height: 300px;
background: #ddd;
}
header {
padding: 20px;
height: 140px;
background: url(https://static.pexels.com/photos/489/dawn-nature-sunset-night.jpg) center top;
background-size: cover;
}
.thumbnail {
width: 100px;
height: 100px;
background: #fff;
border: none;
}
.offset {
width: 100%;
height: 100px;
}
html
<div class="container">
<header>
<div class="offset"></div>
<img src="http://api.adorable.io/avatars/100/[email protected]" class="thumbnail" alt="user photo">
</header>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With