display CENTERED row of images - css

I have a row of three images that are currently displaying just fine.
Now, I want to display two more images right below those three and I want them centered (it would kinda look like an upside down pyramid).
No matter what I do, the bottom row stays left aligned.
Here's the .css
.category
{
width:176px;
font-size:80%;
text-align:center;
float:left;
position:relative;
}
Here's the html:
<div style='width:95%; align:center'>
<div class='category'><a href='individual.php'><img src='images/individual.jpg' style="padding-bottom:0.0em;" border='0' alt='Individual Electronic Neighborhood Watch Alerts by Email and Text Messaging'></a>
<b>Individuals</b></div>
<div class='category'><a href='community.php'><img src='images/community.jpg' style="padding-bottom:0.0em;" border='0' alt='Community based Electronic Neighborhood Watch Alerts by Email and Text Messaging'></a>
<b>Communities</b></div>
<div class='category'><a href='/police'><img src='images/first_respond.jpg' style="padding-bottom:0.0em;" border='0' alt='Police and send Electronic Neighborhood Watch Alerts by Email and Text Messaging'></a>
<b>Fire/Police</b></div>
<br>
<div class='category'><a href='business.php'><img src='images/business.jpg' border='0' alt='Electronic Crime Watch Alerts by Email and Text Messaging for Businesses'></a>
<b>Businesses</b></div>
<div class='category'><a href='utility.php'><img src='images/utility.jpg' border='0' alt='Phone, Cable, Water, Gas and Power Outage Alerts'></a>
<b>Utilities</b></div>
</div>
Here's were you can see the original three: http://www.neighborhoodwatchalerts.com/
Because I dont want the test page to show up in the search engines you can take the above URL and add index2.php onto it and see all 5 images.
Any suggestions would be appreciated!

If you set your category divs to have a css property of display:inline-block, they will obey the text-align: center rule of the container.
here's a fiddle
Markup example
<div class="container">
<div class="category"></div>
<div class="category"></div>
<div class="category"></div>
<br/>
<div class="category"></div>
<div class="category"></div>
</div>
Css
.container{
border: 1px solid #ccc;
text-align: center;
}
.category{
display: inline-block;
width: 100px;
height: 100px;
background: #ccc;
margin: 5px;
}

One quick way to do it is wrap the bottom two divs in another div and center that using margin: 0 auto;.
So something like
<div id="somethingWrapper">
<div class='category'><a href='business.php'>
<img src='images/business.jpg' border='0' alt='yada'></a>
<b>Businesses</b></div>
<div class='category'><a href='utility.php'>
<img src='images/utility.jpg' border='0' alt='yadayada'></a>
<b>Utilities</b></div>
</div>
css
#somethingWrapper{
width:352px; //or something close
margin:0 auto;
}
Fyi... the 0 in the margin might bring the two rows too close. You may need to adjust.

Related

CSS float issue

I have a page where there are two images on top which are floated to left and right as below :
.floatLeft{ float:left;}
.floatRight{ float:right; }
<div>
<img src="firstImage" class="floatLeft"/>
<img src="secondImage" class="floatRight"/>
<!-- wright here -->
</div>
Issue is when i write anything after images (be it in div or a plain text ) and if it goes beyong page width ,
the text after maximum width shifts downwords entirely after images . That is text doesn't wrap inbetween two images
What i understand about float is text should "FLOW" in between two images (unless we use clear which "clears" area around images ) , but its not working like that.
I want to have a text in between two images.
Any help is higly appreciated as a I have done a lot of efforts but it is not working.
Logically, you have 3 blocks of data here, so I suggest using 3 floating divs with set width:
.floatLeft{ float:left}
.div1{width:X%}
.div2{width:Y%}
.div3{width:Z%}
.overflow{overflow: hidden} /* this is optional */
<div class="overflow">
<div class="floatLeft div1">
<img src="firstImage"/>
</div">
<div class="floatLeft div2">
<!-- text here -->
</div">
<div class="floatLeft div3"><!-- or make it float right if you want -->
<img src="secondImage"/>
</div">
</div>
If you want your images a fixed width, try using CSS calc:
.div1{width:100px}
.div2{width:-moz-calc(100%-300px);-webkit-calc(100%-300px);calc(100%-300px);} /* not supported in some browsers */
.div3{width:200px}
But honestly I recommend to go classic way and use a table here:
.table {width:100%;border-collapse:collapse}
.table td {padding:0;margin:0}
.block1 {width:X%} /* or width:Xpx */
.block3 {width:Z%} /* or width:Zpx */
/* do not touch block2 here */
<table class='table'>
<tr>
<td class='block1'>
<img src="firstImage"/>
</td>
<td class='block2'>
<!-- text here -->
</td>
<td class='block3'>
<img src="secondImage"/>
</td>
</tr>
</table>
Remember to wrap your content in "blocks", it always helps when you mark up.
I guess this is the answer that you need jsfiddle
I will explain a little about.
in your div add a class of imgcontainer
in your css, add the following
.imgcontainer{
position:relative;
}
you can add the width of the div, in jsfiddle I set it as 150px. and each of the image is 50px. there you add paragraph with some text
Try this way
<div>
<img src="firstImage" class="floatLeft"/>
<p class="floatLeft">Some textgoes here</p>
<img src="secondImage" class="floatRight"/>
</div>
but give proper width
Another variation is using a CSS version of the table approach proposed by igorpavlov. You have to replace the table/tr/td by divs and to adapt the CSS as proposed here :
.table {width:100%; display: table;}
div{ display: table-cell; vertical-align: top;}
.block1 {width:33%} /* or width:Xpx */
.block3 {width:33%} /* or width:Zpx */
img {width: 100%; height: auto;}
<div class='table'>
<div class='block1'>
<img src="firstImage"/>
</div>
<div class='block2'>
<!-- text here -->
</div>
<div class='block3'>
<img src="secondImage"/>
</div>
</div>
It provides better semantics and works IE8+!

Is it possible to group a set of html elements so that they move together?

When the browser size is changed/on different sized devices, I need a set of html elements that are all semantically related to remain together and move in a block. That is, if one of the elements move to the next "row" due to their not being enough width to contain the whole grouping, ALL of it should move down.
IOW, this is sort of like the "keep together" attribute that some groupings of items in a word processing document have.
To be a little more specific, say that I have collections of the following elements:
1) an anchor tag, filling out a first "column"
2) a collection of tags, to the right of the anchor tag, consisting of:
(a) a div, followed by a <br/>
(b) a cite, followed by a <br/>
(c) another div, followed by a <br/>
(d) two or three anchor tags that are aligned side-by-side at the bottom of the second "column"
So to sum up, if there is not enough room for the second "column" in a "row," rather than keep the in the first "column" and moving the elements in the second column down to the next "row," the in the first column should adhere to its siblings and always remain on the same "row" with them (I'm putting "row" and "column" in quotes because I'm not using an html table, and those exist only in a virtual sense).
If you're finding this a little hard to visualize (I don't blame you), check out the fiddle: http://jsfiddle.net/W7CYC/8/
Note: wrapping the groupings into html5 s did not help.
Here's the code:
HTML:
<div class="yearBanner">2013</div>
<section>
<a id="mainImage" class="floatLeft" href="https://rads.stackoverflow.com/amzn/click/com/0299186342" rel="nofollow noreferrer"><img height="240" width="160" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg"></a>
<div id="prizeCategory" class="category">BIOGRAPHY</div>
<br/>
<cite id="prizeTitle" class="title">Son of the Wilderness: The Life of John Muir</cite>
<br/>
<div id="prizeArtist" class="author">Linnie Marsh Wolfe</div>
<br/>
<img class="floatLeft" height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
<img class="floatLeft" height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
<img class="floatLeft" height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
</section>
<section>
<a class="floatLeft" href="https://rads.stackoverflow.com/amzn/click/com/0299186342" rel="nofollow noreferrer"><img height="240" width="160" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg"></a>
<div class="category">BIOGRAPHY</div>
<br/>
<cite class="title">Son of the Wilderness: The Life of John Muir</cite>
<br/>
<div class="author">Linnie Marsh Wolfe</div>
<br/>
<img height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
<img height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
<img height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
</section>
CSS:
body {
background-color: black;
}
.floatLeft {
float: left;
padding-right: 20px;
padding-left: 5px;
}
.yearBanner {
font-size: 3em;
color: white;
font-family: Verdana, Arial, Helvetica, sans-serif;
float: left;
padding-top: 64px;
}
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
width: 160px;
}
.title {
display: inline-block;
font-family: Calibri, Candara, serif;
color: Yellow;
width: 160px;
}
.author {
display: inline-block;
font-family: Courier, sans-serif;
font-size: 0.8em;
color: White;
width: 160px;
}
jQuery:
$('#prizeCategory').text("Changed Category");
$('#prizeTitle').text("Changed Title that spans two rows");
$('#prizeArtist').text("Changed Author and co-author");
$('#mainImage img').attr("src", "http://ecx.images-amazon.com/images/I/61l0rZz6mdL._SY300_.jpg");
$('#mainImage img').attr("height", "200");
You group items simply with div (or if you want to use section, it is okay too). With a little hint of CSS you can group item inside wrapper. Unfortunately, there is no such attribute than keep together but you can do following:
section.wrapper {
min-width: 400px; /* Minimum width of your wrapper element */
overflow: hidden;
display: inline-block;
}
min-width helps you to keep elements inside wrapper in order. Select a value that best suits your situation.
overflow with value hidden lets your wrapper to understand and add width and height values of floated elements inside.
display with value inline-block let all of wrappers to order next to each other as long as there is enough space, if not, wrapper jumps to other row.
http://www.w3schools.com/ serves great sources to understand and learn CSS, HTML and web technologies in generally. Very useful.
EDIT
As I edited, min-width or width suits better in that situation than max-width
This is not an HTML issue, learn about using CSS absolute position inside of relative positioning:
http://css-tricks.com/absolute-positioning-inside-relative-positioning/
Bootstrap grids
Bootstrap includes a powerful mobile-first flexbox grid system for
building layouts of all shapes and sizes. It’s based on a 12 column
layout and has multiple tiers, one for each media query range. You can
use it with Sass mixins or our predefined classes.
code example :
<div class="row">
<div class="col-4">.col-4</div>
<div class="col-4">.col-4</div>
<div class="col-4">.col-4</div>
</div>
<div class="row">
<div class="col-sm-4">.col-sm-4</div>
<div class="col-sm-4">.col-sm-4</div>
<div class="col-sm-4">.col-sm-4</div>
</div>
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-lg-4">.col-lg-4</div>
<div class="col-lg-4">.col-lg-4</div>
<div class="col-lg-4">.col-lg-4</div>
</div>
<div class="row">
<div class="col-xl-4">.col-xl-4</div>
<div class="col-xl-4">.col-xl-4</div>
<div class="col-xl-4">.col-xl-4</div>
</div>
Output:
This is default output:
and when size of my browser reduce to less than 1200px
Here we have four row and the first row coumns will always at the same tow.
the second row will remain when max width is >=768px
the third row will remain when max width is >=992px and so on.I have inserted this details in G rids options
Here is a gif demo of output
you can mix this classes together.for example
<div class="row">
<div class="col-sm-4 col-xs-6">first-col</div>
<div class="col-sm-4 col-xs-3">second-col</div>
<div class="col-sm-4 col-xs-3">third-col</div>
</div>
mean if small devices I want three column with same with but in very small device I want to first-col be half of space and every two other column be 25% of with.
Now as you can see in every size you can set what behavior every row and every column should do and if you want to always move together you can use col-* classes without any prefix.
Grids Options
(<768px) (≥768px) (≥992px) (≥1200px)
Grid behavior Horizontal at all times Collapsed to start, horizontal above breakpoints
Container width None (auto) 750px 970px 1170px
Class prefix .col-xs- .col-sm- .col-md- .col-lg-
# of columns 12
Column width Auto ~62px ~81px ~97px
Gutter width 30px (15px on each side of a column)
Nestable Yes
Offsets Yes
Column ordering Yes
Here is more detail if you need

Why won't this image align horizontally in css using float properties:

Thanks in advance for any help you can offer me - I'm trying to get this page working for my charity's website. It looks perfect in every browser except IE. In IE, the long, vertical image that is supposed to float next to the other images is not aligning horizontally.
You can see it live here: www.worldofchildren.org
References an external stylesheet here:
<link rel="stylesheet" href="/bannerincludes/boxes.css" type="text/css" media="screen">
Here's the on-page code:
<div style="width:868px;">
<div style="float:left; position: relative;margin-left:25px; margin-top:20px;width:533px;"">
<h1 style="font-family: Adobe Garamond Pro, Garamond, serif; font-size: xx-large; font-weight: 500;
color: #0D9B89;
padding: 0px 0px 0px 0px; line-height:90%;">meet the 2012 honorees</h1>
<div style="float:left;">
<div class="hover-div1" style="margin-right:6px; margin-bottom:6px; float:left;">
<img src="http://www.worldofchildren.org/images/banner/dallas.jpg">
<div class="hover-text">Dallas Jessup <br> 2012 Youth Award Winner</div>
</div>
<div class="hover-div2" style="margin-right:6px; margin-bottom:4px; float:left;">
<img src="http://www.worldofchildren.org/images/banner/craig.jpg" >
<div class="hover-text">Craig Kielburger <br> 15th Anniversary Achievement Award Winner</div>
</div>
<div class="hover-div3" style="margin-bottom:6px; float:left;">
<img src="http://www.worldofchildren.org/images/banner/alina.jpg">
<div class="hover-text">Alina Cho <br> 2012 Board of Governors' Award Winner</div>
</div>
<br>
<br>
<div class="hover-div4" style="margin-right:5px; margin-bottom:5px;float:left;">
<img src="http://www.worldofchildren.org/images/banner/dryoung.jpg" >
<div class="hover-text">Dr. Nilas Young <br> 2012 Health Award Winner</div>
</div>
<div class="hover-div5" style="margin-bottom:5px;float:left;">
<img src="http://www.worldofchildren.org/images/banner/kyle.jpg" >
<div class="hover-text">Kyle Weiss <br> 2012 Youth Award Winner</div>
</div>
</div>
<div style="float:right !important;">
<div class="hover-div6" style="margin-bottom:5px;">
<img src="http://www.worldofchildren.org/images/banner/benito.jpg" >
<div class="hover-text"><a href="http://www.worldofchildren.org/honorees/391" style="color:#fff;">
Benoît Duchâ teau-Arminjon<br> 2012 Humanitarian Award Winner</a></div>
</div>
</div>
</div>
<div style="float:right; margin-top:20px;margin-right:30px; ">
<h1 style="font-family: Adobe Garamond Pro, Garamond, serif; font-size: xx-large; font-weight: 500;
color: #0D9B89;
padding: 0px 0px 0px 0px; line-height:90%;">15th annual awards</h1>
<p style="max-width:250px; font-family:helvetica;sans-serif; font-size:14pt;color:#777; font-weight:lighter; line-height:100%;">Join us as we celebrate the work of six exceptional heroes who have dedicated their lives to serving children in need. Much more than a ceremony, our Awards change the lives of those who attend and the children our Honorees serve.</p>
<br>
<center><img src="http://www.worldofchildren.org/images/banner/lm.jpg" border="0"><br>
Interested in Sponsorship Opportunities?<br>
Click here
</center>
</div>
</div>
Put a width of width: 420px; on the DIV you have floated left (the first chunk of boxes). Even though it is floated, IE is giving it the full width of it's parent, so there isn't room for the boxes on the right.
Add a width to your floated containers. Right now, you have no width and IE is filling the inline space with your left floated element.
To debug these things in IE, you can use the IE developer tools.
In IE, hit your F12 key.
In the developer tools, click the "mouse" icon in the top left. This is your selector tool.
Will the selector tool, select the area of your website you are having an issue with.
In your case, you can see the floated left element is too wide, because it's width is currently dynamic. IE is making it fill 100% of the horizontal area.
Instead of float, this works in IE9
position: absolute;
right: 0;
bottom: 0;

Text Not Aligning Properly - font-size issue?

I'm trying to align text on top of an image in such a way that it remains aligned even if the underlying image is increased/decreased in size. I'm using px values that were taken from Photoshop measurements.
Please take a look at http://jsfiddle.net/dXNgx/. The word "For" is being overlaid on the image. It measures 20px in height, but when placed on the image, font-size: 20px; results in a "For" that is smaller than the underlying image. What gives?
You need to place the div.layer outside of the #page1 as otherwise -moz-transform:scale(.5); is applied to it.
Zoom In + | Zoom Out -
<div style="position:relative;">
<div style="-moz-transform:scale(.5); -moz-transform-origin:left top;position:absolute;" class="page" id="page1">
<div class="layer" style="z-index:1;">
<img src="http://cobalt.xtracta.com/images/image.jpg" style="width:2480px; height:3508px">
</div>
</div>
<div class="layer" style="z-index:2;">
<div style="font-size: 20px; position:absolute; color:#F00; top: 1550px; left: 306px;">For</div>
</div>
</div>
http://jsfiddle.net/dXNgx/2/

Absolute positioning in gmail emails

I have a client who wants to send gift certificates to people who sign up on their site. They want it all designed out, so I can't just send a text email. I'm trying to position text over the image so that it can still be dynamic.
I'm trying to do this with absolute positioning. Some email systems love it. Some hate it. Gmail happens to hate it.
We're using MailChimp for the campaign. Here is the full source of the email. Following that is just the snippet that isn't working.
<html>
<head>
<!-- This is a simple example template that you can edit to create your own custom templates -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>*|MC:SUBJECT|*</title>
<style type="text/css">body{background-color:#bab145;text-align:center;}#layout{border:5px solid #999999;background:#ffffff;margin:10px auto;text-align:left;}#header{background-color:#cccccc;padding:0px;color:#333333;font-size:30px;font-family:Georgia;text-align:left;}#content{font-size:13px;color:#4d4d4d;font-family:Helvetica;line-height:1.25em;padding:10px 30px;}.primary-heading{font-size:28px;font-weight:bold;color:#8b0000;font-family:Georgia;line-height:150%;margin:25px 0 0 0;}.secondary-heading{font-size:20px;font-weight:bold;color:#000000;font-style:normal;font-family:Georgia;margin:25px 0 5px 0;}#footer{background-color:#eeeeee;border-top:0px none #ffffff;padding:20px;font-size:10px;color:#333333;line-height:100%;font-family:Verdana;}#footer a{color:#800000;text-decoration:underline;font-weight:normal;}a,a:link,a:visited{color:#800000;text-decoration:underline;font-weight:normal;}</style></head>
<body style="background-color: #bab145;text-align: center;">
<table id="layout" border="0" cellspacing="0" cellpadding="0" width="600" style="border: 5px solid #999999;background: #ffffff;margin: 10px auto;text-align: left;">
<tr>
<td id="content" style="font-size: 13px;color: #4d4d4d;font-family: Helvetica;line-height: 1.25em;padding: 10px 30px;"><div style="height:243px; width: 500px; position: relative;">
<img src="http://getfreepellets.com/images/GC_flat.jpg" style="position: absolute;">
<div style="position: absolute; top: 110px; left: 130px;">
*|FNAME|* *|LNAME|*</div>
<div style="position: absolute; top: 140px; left: 130px;">
GetFreePellets.com</div>
<div style="position: absolute; top: 166px; left: 130px;">
$100</div>
<div style="position: absolute; top: 200px; left: 370px;">
*|COUPONCODE|*</div>
</div>
</td></tr>
<tr>
<td id="footer" style="background-color: #eeeeee;border-top: 0px none #ffffff;padding: 20px;font-size: 10px;color: #333333;line-height: 100%;font-family: Verdana;">
<p>view email in browser | Unsubscribe *|EMAIL|* | Update your profile | Forward to a friend</p>
<p>*|LIST:DESCRIPTION|*</p>
<p>*|HTML:LIST_ADDRESS_HTML|*</p>
<p>Copyright (C) *|CURRENT_YEAR|* *|LIST:COMPANY|* All rights reserved.</p>
</td>
</tr>
</table>
<span style="padding: 0px;"></span>
<center><table width="95%" style="clear:both;margin:0px !important;padding:0px !important;margin-top:20px !important;border-top:1px solid #999 !important;border-bottom:1px solid #999 !important;" cellpadding="0" cellspacing="0"><tr>
<td align="left" style="padding:10px !important;margin:0px !important;color:#666 !important;background:#CCC !important;width:50% !important;border-bottom 1px solid #999 !important;font-family:Verdana,Arial,Sans !important;font-size:11px !important;font-weight:normal !important;font-style:normal !important;text-decoration:none !important;vertical-align:middle !important;text-align:left !important;">
Sent to *|EMAIL|*. Unsubscribe |
Update Profile |
Forward to a Friend
</td>
<td align="right" style="padding:10px !important;margin:0px !important;color:#666 !important;background:#CCC !important;width:50% !important;border-bottom 1px solid #999 !important;vertical-align:middle !important;text-align:right !important;">
*|REWARDS|*
</td>
</tr></table></center></body>
</html>
And just the snippet I'm worried about:
<tr>
<td id="content" style="font-size: 13px;color: #4d4d4d;font-family: Helvetica;line-height: 1.25em;padding: 10px 30px;"><div style="height:243px; width: 500px; position: relative;">
<img src="http://getfreepellets.com/images/GC_flat.jpg" style="position: absolute;">
<div style="position: absolute; top: 110px; left: 130px;">
*|FNAME|* *|LNAME|*</div>
<div style="position: absolute; top: 140px; left: 130px;">
GetFreePellets.com</div>
<div style="position: absolute; top: 166px; left: 130px;">
$100</div>
<div style="position: absolute; top: 200px; left: 370px;">
*|COUPONCODE|*</div>
</div>
</td></tr>
Note: MailChimp merge variables are those things between | and |.
Here is an image of what it looks like in Entourage. The red bar is a real name, so.. ya:
Email working http://img.skitch.com/20100804-m91tny1ck75adfibga6cundcxr.jpg
And here is it in gmail (I know the name isn't censored):
Email not working http://img.skitch.com/20100804-rfrb1fejjubqr4id56yq1xihdp.jpg
Any ideas on how to get this working in gmail?
Unfortunately, you can't use position: absolute.
Also, because Outlook is using the Word HTML renderer, you will also run into problems using absolute positioning.
Most HTML emails are laid out with tables.
Check this out.
Please note that is not a foolproof solution. I had some problems with it on Outlook and need to disable it.
So first of all you need to set a container to position against.
<div style="width:300px;height:300px;">
</div>
Then place an element inside that, set display as inline-block and position it with margin-top and margin-left.
<div style="width:300px;height:300px;">
<div style="width:100px;height:100px;margin-top:100px;margin-left:100px;display:inline-block;">
</div>
</div>
N.B. Unfortunately negative values in the margin won't work in Gmail, Outlook.com or 365.
The element is now behaving similar to position:relative but we want position:absolute so as not to affect the flow of any neighbouring elements. To achieve this wrap the inner element in a div with max-height:0;max-width:0 this now mean that div takes up no space on the page, but the overflow can still be seen.
<div style="width:300px;height:300px;">
<div style="max-height:0;max-width:0;overflow: visible;">
<div style="width:100px;height:100px;margin-top:100px;margin-left:100px;display:inline-block;">
</div>
</div>
</div>
You can now place multiple elements in that container and position them absolute. In this example I've added outlines and semi transparent background colours to clear display the outcome.
<div style="width:300px;height:300px;outline:2px solid black;margin:0 auto;">
<div style="max-height:0;max-width:0;overflow: visible;">
<div style="width:100px;height:100px;margin-top:100px;margin-left:100px;display:inline-block;outline:2px solid red;text-align:center;line-height:100px;font-size:50px;background:rgba(255,0,0,0.2)">
1
</div>
</div>
<div style="max-height:0;max-width:0;overflow: visible;">
<div style="width:100px;height:100px;margin-top:150px;margin-left:150px;display:inline-block;outline:2px solid blue;text-align:center;line-height:100px;font-size:50px;background:rgba(0,0,255,0.2)">
2
</div>
</div>
<div style="max-height:0;max-width:0;overflow: visible;">
<div style="width:100px;height:100px;margin-top:50px;margin-left:50px;display:inline-block;outline:2px solid green;text-align:center;line-height:100px;font-size:50px;background:rgba(0,255,0,0.2)">
3
</div>
</div>
</div>
Outlook
Ok so it still doesn't work in desktop Outlook but it does work pretty much everywhere else I've test.
But please do use this wisely. Do consider Outlook, perhaps a VML fallback or simply using Outlook conditional comments.
Source: https://web.archive.org/web/20170824110806/http://blog.gorebel.com/absolute-positioning-in-email
I would suggest doing the whole thing as a table (div support is not 100% reliable in email clients). Use border properties to give the table the green border. Insert the image of the logo/banner in the first row of the table (merged three columns). Use the next 3 rows for the To, From and Amount (with the values in the merged second and third columns). And use the last column of the last row for the cupon code.
If you really want the double border then you can either wrap the table in a div or for maximum compatibility, wrap the table in a 1 column, 1 row table.
Yes it's ugly but email clients have extremely buggy and/or old implementations of HTML so this is not the time or place to be squirmish about ugly, non-web2.0-looking code.
See the link posted by alex for more info.
(I know I'm answering 4 years later... but probably it will help somebody...)
If you look carefully, you don't have background images, you have possibly 10 images or more, many background colors and a complex table.
There's no image behind a text. You could divide your table and compose your background image as multiple image fragments, and match the text's background color with these images.
Really... in this template there are no "required" background images, just a complex table.

Resources