Forum Moderators: not2easy

Message Too Old, No Replies

Layout problem

Getting text to wrap

         

killerbean

6:53 pm on May 30, 2003 (gmt 0)

10+ Year Member



I'm trying to do a layout where I have a gray background, a content area for text with a white background that is padded by 10px, and an image aligned in the upper-right corner of the white box (that doesn't get affected by the padding). I want the text in the content area to break at the image. Instead, I'm getting a content area that either covers the image totally (IE) or where the text just continues on its line across the image (Opera). How do I get the image that is outside the "content" area to affect text in the "content" area? Or, how do I put the image inside the "content" area, but align it to the "container" box?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

#container {
width: 750px;
margin: 0;
background-color: #FFFFFF;
min-height: 368px;
text-align: left;
}

#content {
width: 730px;
padding: 10px;
min-height: 348px;
}

.image {
float: right;
clear: none;
padding-left: 10px;
}

<div id="container">

<img class="image" src="image.jpg" width="250" height="145" align="right">

<div id="content">
<p>Content goes here. If you write enough, it'll overlap the image.</p>
</div>

</div>

drbrain

7:04 pm on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You want the text to flow around the image:


text text text ¦img¦
text text text text

Put img inside #content and add:

[edit whoops! missed this]

.image { position: relative; top: -10px; right: -10px; }

To get the image to overlay the padding.

[edited by: drbrain at 7:13 pm (utc) on May 30, 2003]

joshuakaufman

7:07 pm on May 30, 2003 (gmt 0)

10+ Year Member



I wouldn't recommend using HTML presentational attributes, such as align, at the same time as CSS. They don't work well together. That may solve some of your problems.

killerbean

7:39 pm on May 30, 2003 (gmt 0)

10+ Year Member



OK, that takes care of the padding issue, but Opera 7.11 is still overlaying the image with the text. IE is wrapping it correctly. Any ideas why?

drbrain

7:49 pm on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Most likely a bug, Mozilla shows it just fine.