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 4 of 4

Thread: Help?!?

  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help?!?

    I want to make the div which happens to be the white area automatically adjust so that the image fits the div.


    My HTML:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <link rel="stylesheet" type="text/css" media="screen" href="style.css">
    <title>TechBot</title>
    </head>
    <body>
    <center><img class="banner" src="techbot_banner.png" alt="TechBot banner"/></center>
    <div class="container">
    <center><h1>Lorem Ipsum</h1></center>
    <img class="img1" src="ads.png">
    <p><span class="txt1"><a href="http://youtube.com">Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit. Aenean sollicitudin egestas felis, et dapibus lectus dignissim vel. Pellentesque urna ligula, accumsan eu consequat vitae, condimentum ac mi. Sed at nisl mauris, quis interdum tellus. Nunc fermentum, nulla ut volutpat euismod, lacus leo elementum magna, ut aliquam dolor tellus in diam. Phasellus luctus arcu a sapien porta tincidunt. Quisque aliquet molestie dui sit amet dictum. Nunc scelerisque consequat faucibus. Duis sem nunc, semper vitae interdum sit amet, tincidunt vitae est. Praesent laoreet rhoncus arcu, in molestie massa tempus rutrum. Quisque et neque sit amet sem mollis pharetra in eget neque. Nulla euismod eleifend bibendum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Morbi ullamcorper tempor nunc id tempus. Nulla vitae felis diam, in vulputate tortor. In sagittis cursus erat, non volutpat sem tincidunt sed. Quisque consequat hendrerit lacinia. Nulla massa sem, varius vel vehicula at, suscipit et libero. Donec sodales lacinia volutpat. Donec sodales tincidunt justo, nec hendrerit nibh commodo ac.</span></p>
    </div>
    </body>
    </html>

    CSS:
    body {
    font-family: calibri;
    background: rgb(244, 240, 236);
    }
    .txt1 {
    text-align:justify;
    color: #000000
    }
    .container {
    width: 692px;
    border: 1px solid black;
    margin:0 auto;
    margin-top: 20px;
    background-color: #ffffff;
    padding: 4px
    }
    a:link {
    color: #00ffff;
    text-decoration: none;
    }
    .banner {
    border: 1px solid black;
    }
    .img1 {
    float: right;
    }



  • #2
    Registered User
    Join Date
    Feb 2011
    Posts
    82
    Thanks
    15
    Thanked 3 Times in 3 Posts
    wrap code in [code] [/-code] (no dash)

    since your images are on your computer, I'm not sure if I can help you.
    Last edited by Aurora.Light; 04-05-2011 at 12:17 AM.

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,667
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello gabriel515,
    I just put some random sizes and a background color on that image for demonstration. If you clear the float then .container will expand to include it.
    Try this -
    Code:
    .container {
    	width: 692px;
    	margin: 20px auto;
    	padding: 4px;
    	border: 1px solid black;
    	background: #fff;
    overflow: auto;
    }
    .img1 {
    height: 500px;
    width: 100px;
    float: right;
    background: #f00;
    }
    See this explanation of how overflow: auto; clears your floats.

    And, like Aurora.Light mentioned, when posting code in the forum, please use the code tags, &#91;code&#93;&#91;/code&#93; - available with the # button in the post edit window.
    This will wrap your code in a scroll box which greatly helps the readability of your post.
    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

  • #4
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    something like this?

    This floats the image right and extends the div border to below the image if the image is higher than the text.

    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>
            <title></title>
            <style type="text/css">
                #content {
                    border: 1px solid red;
                    padding: 10px 10px 10px 10px;
                    overflow: hidden;
                }
                #content img {
                    float: right;
                    margin-left: 20px;
                }
            </style>
        </head>
        <body>
            <div id="content">
                <img src="pic1.jpg" alt="" />
                Lorem ipsum dolor sit amet, tellus et. Molestie auctor nisl faucibus ut, lorem tortor mattis, fusce nullam enim fringilla vel.
                Mauris vitae gravida dolor praesent. Id in nascetur aut odio, nam et. Pede libero bibendum sit felis pretium sodales, fusce
                pharetra vestibulum bibendum morbi ultricies nullam, est nulla, id amet mollis.
            </div>
        </body>
    </html>


  •  

    Posting Permissions

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