Hi guys, I’ve trying to achieve the following.
I want to have a div element floating on the right 100px from the top and the rest of content is filled with text.
I can achive the following:
Have the image float on right, but 0px from top, using simple
float:right
If i put my
p
image
in my html, the image’s position (y-coordinate) will change as the content changes (I want it always 100px from top no matter what).
I’ve tried to add another right-floated element with width 10px; (or so) “on top”. This places my image correctly, but the the text overflows beneath the floated image (note that if my top div has width greater than my image everything works fine). I’ve tested this in both FF 3 and IE7 with the same outcome
Can anyone help me with this ... thank you
p.s. here’s my html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title>float</title>
<style type="text/css">
.content { width: 400px; background: #FFFF00; padding: 5px; }
.floatright { float: right; height: 100px; border: 1px solid #000; }
.offset { width: 10px; }
.imgholder { width: 100px; clear: right; }
</style>
</head>
<body>
<div class="content">
<div class="floatright offset"></div>
<div class="floatright imgholder"><h1>image</h1></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam posuere. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Cras ornare. Vestibulum a nulla id velit elementum imperdiet. Nam a purus. Suspendisse non enim. Nullam id sem. Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas aliquet varius tellus.
Aliquam sed nunc eu tortor semper vulputate. Nunc risus.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam posuere. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Cras ornare. Vestibulum a nulla id velit elementum imperdiet. Nam a purus. Suspendisse non enim. Nullam id sem. Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas aliquet varius tellus. Aliquam sed nunc
eu tortor semper vulputate. Nunc risus.</p>
</div>
</body>
</html>