Thanks to Erik's help on my last question, I was able to get my icon-left, text-right floating div example working:
http://tanguay.info/web/examples/tablelessItemLayout
However, because the images are various width's, I had to cheat a bit by putting in-line styles in some of the tags.
How can I change this code so that:
- there are no in-line styles
- it supports various sized image widths
Code:
<html>
<style>
* { margin: 0; padding: 0 }
body {
padding: 20px;
text-align: center;
background-color: #333;
}
p {
margin: 0 0 10px 0;
}
#content {
width: 600px;
margin-left: auto;
margin-right: auto;
background: brown;
border: 1px solid #555;
text-align: left;
}
.item {
margin: 20px;
background-image:url('paperBackground.jpg');
padding: 20px;
}
.itemIcon {
float:left;
}
.itemIcon p {
font-size: 8pt;
margin: 5px 0 0 0;
}
.itemBody h1 {
font-size: 18pt;
color: brown;
margin: 0 0 10px 0;
}
.clear {
clear: both;
}
</style>
<body>
<div id="content">
<div class="item">
<div class="itemIcon" style="width: 70px; padding-left: -80px">
<img src="icon.png" alt=""/>
<p>This is the caption that is under the image.</p>
</div>
<div class="itemBody" style="margin-left: 80px">
<h1>This is the first item</h1>
<p>Aliquid aliquam fabulas duo an, eu delenit intellegebat has, in sit commodo aliquip. Inermis neglegentur vis an, ea mei habeo animal verterem. Cum vivendo intellegam disputando id, usu id dicta harum convenire. Cibo corpora ut pri, sed legere probatus aliquyam no, vidisse suscipiantur eu mea. Modus etiam concludaturque pro an, ut latine quaeque per. Harum ignota mnesarchum pri ad, duo et diam oblique epicurei, pri ne vivendo omnesque epicurei.</p>
<p>Aliquid aliquam fabulas duo an, eu delenit intellegebat has, in sit commodo aliquip. Inermis neglegentur vis an, ea mei habeo animal verterem. Cum vivendo intellegam disputando id, usu id dicta harum convenire. Cibo corpora ut pri, sed legere probatus aliquyam no, vidisse suscipiantur eu mea. Modus etiam concludaturque pro an, ut latine quaeque per. Harum ignota mnesarchum pri ad, duo et diam oblique epicurei, pri ne vivendo omnesque epicurei.</p>
</div>
</div>
<div class="item">
<div class="itemIcon" style="width: 160px; padding-left: -170px">
<img src="bigIcon.png" alt=""/>
<p>This is the caption that is under the image and it is a very long text so it is going to wrap a couple times here in the left column under the image.</p>
</div>
<div class="itemBody" style="margin-left: 170px">
<h1>This is the second item</h1>
<p>Aliquid aliquam fabulas duo an, eu delenit intellegebat has, in sit commodo aliquip. Inermis neglegentur vis an, ea mei habeo animal verterem. Cum vivendo intellegam disputando id, usu id dicta harum convenire. Cibo corpora ut pri, sed legere probatus aliquyam no, vidisse suscipiantur eu mea. Modus etiam concludaturque pro an, ut latine quaeque per. Harum ignota mnesarchum pri ad, duo et diam oblique epicurei, pri ne vivendo omnesque epicurei.</p>
<p>Aliquid aliquam fabulas duo an, eu delenit intellegebat has, in sit commodo aliquip. Inermis neglegentur vis an, ea mei habeo animal verterem. Cum vivendo intellegam disputando id, usu id dicta harum convenire. Cibo corpora ut pri, sed legere probatus aliquyam no, vidisse suscipiantur eu mea. Modus etiam concludaturque pro an, ut latine quaeque per. Harum ignota mnesarchum pri ad, duo et diam oblique epicurei, pri ne vivendo omnesque epicurei.</p>
</div>
</div>
</div>
</body>
</html>