For a challenging task of creating an email template, I encountered a problem with stacking one element on top of another:
Usually in HTML/CSS, it would look like this:
<div class="element">
<div class="icon"></div>
<div class="count">6</div>
</div>
.element {
position: relative;
height: 60px;
width: 60px;
}
.icon {
position: absolute;
bottom: 0;
background: url('http://www.veryicon.com/icon/ico/System/Sticker%20Pack%201/Chat.ico') no-repeat;
width: 48px;
height: 48px;
background-size: 100%;
}
.count {
position: absolute;
right: 5px;
width: 20px;
text-align: center;
display: inline-block;
padding: 5px;
background-color: #F33689;
color: #FFF;
font-family: sans-serif;
border-radius: 5px;
font-size: 18px;
}
View the result here
Is there a way to achieve this outcome using techniques that are compatible with email clients and will work across the board?
My potential solutions include:
- Negative margins (not universal)
- Background image (not universal)
- Position absolute/relative (not universal)
- ...?
Thank you