?
Solved

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

Posted on 2004-08-25
13
Medium Priority
?
708 Views
Last Modified: 2008-02-20
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
Comment
Question by:Havin_it
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
13 Comments
 
LVL 11

Expert Comment

by:neester
ID: 11891764
Please post the code because its hard to understand what you have.

Cheers :)
0
 
LVL 10

Author Comment

by:Havin_it
ID: 11891841
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
 
LVL 11

Expert Comment

by:neester
ID: 11892101
OK firstly a point about CSS.
You can use ShortHand to code the borders.

      
<deleted text from a mispost>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:neester
ID: 11892106
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
 
LVL 11

Expert Comment

by:neester
ID: 11892149

.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
 
LVL 11

Assisted Solution

by:neester
neester earned 225 total points
ID: 11892164
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
 
LVL 11

Expert Comment

by:neester
ID: 11892196
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
 
LVL 10

Author Comment

by:Havin_it
ID: 11892211
Thanks, that's a valid observation but doesn't seem likely to solve my problem.
0
 
LVL 11

Expert Comment

by:neester
ID: 11892226
Adding <br style="clear:both; height: 0px; display: inline; margin: 0; padding: 0;" />
After the end of your first <p> didnt fix it?
0
 
LVL 10

Author Comment

by:Havin_it
ID: 11892289
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
 
LVL 31

Accepted Solution

by:
seanpowell earned 150 total points
ID: 11892577
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
 
LVL 10

Author Comment

by:Havin_it
ID: 11896033
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
 
LVL 31

Expert Comment

by:seanpowell
ID: 11896722
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question