Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 713
  • Last Modified:

inline images in a DIV - how to stretch the border to their bottom?

Hi,

I have a series of inline DIVs, inside each of which is an image (floated left or right) and text. The <img> tag is inside the <p>tag so as to be flush with the top of the first line of text. Each DIV has a CSS border. The problem is, the border (and indeed the DIV itself) only contains the text, so if the image is tall and the text short, the image 'breaks out' of the border and can even intrude onto the next DIV.

In short, the container is not containing the element contained therein. Frustrating!

Might the assembled luminaries have a fix for this?
0
Havin_it
Asked:
Havin_it
  • 7
  • 4
  • 2
2 Solutions
 
neesterCommented:
Please post the code because its hard to understand what you have.

Cheers :)
0
 
Havin_itAuthor Commented:
Ah. good point. Here ya go.

Example HTML:

<div class="boxBorder">
<p class="header">
<a href="http://www.witcherytours.com/witcherytours_Video1.html" target="_blank"><img class="imgLeft" src="images/royalmile.jpg" alt="Adam Lyal's Royal Mile video - Click to buy" border="0" /></a>
Adam Lyal's Royal Mile - Tales of Old Edinburgh</p>
<p class="smallBodyText">The distinctive character of Edinburgh's most historic
      thoroughfare is vivdly brought to life on this exciting and unusual video.
      Our guide through the closes and wynds of the mile is Adam Lyal (deceased),
      hanged
      in the Grassmarket in 1811. Adam is now the city's most famous and charismatic
ghost. <br />
He introduces us to the grandeur of the Royal Mile architecture,
      regales us with tales of execution, witchcraft, plague and torture. We meet
      intriguing
      characters from Edinburgh's colourful and eventful past - from John Knox
      to      the Foule Clenger. Adam also visits the famous tattoo at the castle and
      soaks      up the carnival atmosphere of the Edinburgh Festival.
      <br />
  This highly entertaining and informative video offers visitor and local alike
      a fascinating and unique view of one of the world's best-loved and most beautiful
      cities. Not to be missed!<br />
</p>
</div><br />

CSS classes:

.boxBorder {
      border-top-width: 1px;
      border-top-style: solid;
      border-top-color: #999999;
      border-right-color: #999999;
      border-bottom-color: #999999;
      border-left-color: #999999;
      border-bottom-width: 2px;
      border-bottom-style: groove;
      border-right-width: 2px;
      border-left-width: 1px;
      border-right-style: groove;
      border-left-style: solid;
      padding: 12px 8px;
      width: 95%;
}

.imgLeft {
      margin-right: 10px;
      float: left;

}

.header {
      font-family: Geneva, Arial, Helvetica, sans-serif;
      font-size: 14px;
      text-align: left;
      font-weight: bold;
      text-decoration: underline;
      margin-top: 0px;
      margin-left: 6px;
}
0
 
neesterCommented:
OK firstly a point about CSS.
You can use ShortHand to code the borders.

      
<deleted text from a mispost>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
neesterCommented:
Sorry.
What the hell happened there?


It meant to read:

.boxBorder {
     border-top-width: 1px;
     border-top-style: solid;
     border-top-color: #999999;
     border-right-color: #999999;
     border-bottom-color: #999999;
     border-left-color: #999999;
     border-bottom-width: 2px;
     border-bottom-style: groove;
     border-right-width: 2px;
     border-left-width: 1px;
     border-right-style: groove;
     border-left-style: solid;
     padding: 12px 8px;
     width: 95%;
}

CAN BECOME:

.boxBorder {
     border-top: 1px solid #999;
     border-right: 2px groove #999;
     bordet-bottom: 2px groove #999;
     border-left: 1px solid #999;
     padding: 12px 8px;
     width: 95%;
}
0
 
neesterCommented:

.boxBorder {
     border-top: 1px solid #999;
     border-right: 2px groove #999;
     border-bottom: 2px groove #999; <<<< error on prev. post... now its fixed
     border-left: 1px solid #999;
     padding: 12px 8px;
     width: 95%;
}
0
 
neesterCommented:
Here Simple fix:

this is the page i used to test with: ( I ADDED <div style="clear:both; height: 0px;"></div> to the code, after hte 1st <p>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
      <title>Nyt dokument</title>
<META NAME="generator" CONTENT="TSW WebPad">
<style>
.boxBorder {
     border-top: 1px solid #999;
     border-right: 2px groove #999;
     border-bottom: 2px groove #999;
     border-left: 1px solid #999;
     padding: 12px 8px;
     width: 95%;
}

.imgLeft {
     margin-right: 10px;
     float: left;

}

.header {
     font-family: Geneva, Arial, Helvetica, sans-serif;
     font-size: 14px;
     text-align: left;
     font-weight: bold;
     text-decoration: underline;
     margin-top: 0px;
     margin-left: 6px;
}
</style>
</head>

<body>

<div class="boxBorder">
<p class="header">
<a href="http://www.witcherytours.com/witcherytours_Video1.html" target="_blank"><img style="height: 200px;" class="imgLeft" src="http://www.witcherytours.com/images/royalmile.jpg" alt="Adam Lyal's Royal Mile video - Click to buy" border="0" /></a>
Adam Lyal's Royal Mile - Tales of Old Edinburgh</p>
<div style="clear:both; height: 0px;"></div>
<p class="smallBodyText">The distinctive character of Edinburgh's most historic
     thoroughfare is vivdly brought to life on this exciting and unusual video.
     Our guide through the closes and wynds of the mile is Adam Lyal (deceased),
     hanged
     in the Grassmarket in 1811. Adam is now the city's most famous and charismatic
ghost. <br />
He introduces us to the grandeur of the Royal Mile architecture,
     regales us with tales of execution, witchcraft, plague and torture. We meet
     intriguing
     characters from Edinburgh's colourful and eventful past - from John Knox
     to     the Foule Clenger. Adam also visits the famous tattoo at the castle and
     soaks     up the carnival atmosphere of the Edinburgh Festival.
     <br />
  This highly entertaining and informative video offers visitor and local alike
     a fascinating and unique view of one of the world's best-loved and most beautiful
     cities. Not to be missed!<br />
</p>
</div>


</body>
</html>
0
 
neesterCommented:
SORRY...
:)


REPLACE:
<div style="clear:both; height: 0px;"></div>
WITH
<br style="clear:both; height: 0px; display: inline; margin: 0; padding: 0;" />


I changed it to a DIV without testing :)
Didnt work the way i thought :)
enjoy that fix...
if it suits what you wanted.
I hope :)
0
 
Havin_itAuthor Commented:
Thanks, that's a valid observation but doesn't seem likely to solve my problem.
0
 
neesterCommented:
Adding <br style="clear:both; height: 0px; display: inline; margin: 0; padding: 0;" />
After the end of your first <p> didnt fix it?
0
 
Havin_itAuthor Commented:
Sorry, that was before your last posts. However inserting the <br> doesn't do it either - the next paragraph now aligns to the bottom of the image.
0
 
seanpowellCommented:
Hi Havin_it,

Have a read through this:
http://www.complexspiral.com/publications/containing-floats/

I don't want to post any more code yet becuase the thread is already becoming long...
0
 
Havin_itAuthor Commented:
Ah Mr Powell. A typically graceful response. In fairness it is the same one proposed by neester, but the background info allowed me to understand what was amiss.

@neester: your answer was correct for my needs, the problem was I didn't understand its functionality and placed it incorrectly (albeit via your guidelines). Placing the 'clearer' DIV below the remaining paras within the bordered DIV did the trick. You also rang my bell about my Dreamweaver bloat-code, so you get a slightly higher cut of the cake for sheer cheekiness ;)

Thanks all
0
 
seanpowellCommented:
Thanks Havin_it :-)

(It's the old bit about the horse and drinking, just wanted to mkae sure you knew what was going on...)


0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now