Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Float Help

  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Float Help

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

    Code:
    #rightnav
    {
    float: right;
    width: 160px;
    margin: 0;
    padding: 1em;
    }
    Code:
    <div id="rightnav">
    <img src="images/Mot_logo.png">
    </div>

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,748
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    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.
    Code:
    <!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>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    New Coder
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    w00ps i explained wrong sorry...i have text in a content id and then i have the rightnav as another id...
    Code:
    #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

  • #4
    New Coder
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol all i had to do is place the rightnav div before the content

  • #5
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,748
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    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!
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #6
    New Coder
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol sorry m8


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •