...

View Full Version : Float Help



rushy
01-27-2007, 05:56 PM
I have a float setup so i can have a pictures to the right of the text but the picture keeps going underneath the text...


#rightnav
{
float: right;
width: 160px;
margin: 0;
padding: 1em;
}


<div id="rightnav">
<img src="images/Mot_logo.png">
</div>

Excavator
01-27-2007, 06:23 PM
Hello Rushy,
For text to wrap an image you need to float that image. Your floating your div but doing nothing to the image.
In this example I gave the image a class and styled that class in the CSS.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
#rightnav
{
width: 160px;
margin: 0;
padding: 1em;
}
.float_right {
float: right;
}
</style>
</head>
<body>
<div id="rightnav">
<img src="images/Mot_logo.png" alt="unknown image" width="40" height="140" class="float_right" />
<p>some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right. some text that will wrap the image to the right.</p>
</div>
</body>
</html>

rushy
01-27-2007, 06:34 PM
w00ps i explained wrong sorry...i have text in a content id and then i have the rightnav as another id...

#content {
height:350px;
background-color:#ffffff;
padding-left:5px;
padding-top:5px;
}

#rightnav
{
float: right;
width: 160px;
margin: 0;
padding: 1em;
}


and it always ends up underneath the content

rushy
01-27-2007, 10:48 PM
lol all i had to do is place the rightnav div before the content

Excavator
01-28-2007, 12:10 AM
A lot to be said for posting your ENTIRE code when asking a question. Saves a lot of guess work - I've proved time and again that I suck at reading minds!

rushy
01-28-2007, 10:28 AM
lol sorry m8



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum