+ Reply to Thread
Results 1 to 4 of 4

Thread: Common Problem

  1. #1
    sdchilderley is offline x10Hosting Member sdchilderley is an unknown quantity at this point
    Join Date
    Dec 2009
    Location
    Peterborough UK
    Posts
    22

    Common Problem

    what i want to do, the container would normaly expand if "position:absolute" was not on the content boxs.

    But i need the content boxs positioned at exactly that and if i remove position absolute, the content boxs will all default to one position top right corner, therefore i have no control over there position...

    At the same time i need control over there positions but if theres more data in the bottom left box, it needs to expand the container aswell as itself... understand?


    The CSS
    Code:
    @charset "utf-8";
    /* CSS Document */
    
    body {
    margin:0px;
    padding:0px;
    text-align:center;
    
    
    }.container {
        margin: 0 auto;
        border: thin solid #FF0000;
    width:400px;
    
    }.contentbox1 {
        position:absolute;
        right:325px;
        width:117px;
        top:125px;
        border: thin solid #00FF00;
        height: 119px;
    
    
    }.contentbox2 {
        position:absolute;
        right:450px;
        width:120px;
        top:125px;
        border: thin solid #00FF00;
        height: 118px;
    
    
    }.contentbox3 {
        position:absolute;
        right:326px;
        width:116px;
        top:8px;
        border: thin solid #00FF00;
        height: 108px;
    
    
    }.contentbox4 {
        position:absolute;
        right:451px;
        width:119px;
        top:8px;
        border: thin solid #00FF00;
        height: 107px;
    
    
    }

    The HTML
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Aboutghosts Example</title>
    <link rel="stylesheet" type="text/css" href="css/default.css">
    </head>
    
    <body>
    
    
    <div class="container">
    
    
    <div class="contentbox1">content box 4</div>
    <div class="contentbox2">
      <p>content box 3</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>Tons of comments here in content box 3</p>
    </div>
    <div class="contentbox3">content box 2</div>
    <div class="contentbox4">content box 1</div>
    
    
    </div>
    
    
    
    </body>
    </html>

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Common Problem

    Absolutely positioned elements are taken out of the normal flow and never used to calculate the height of an ancestor. If you don't want that behavior, don't use absolute positioning. Instead, use elastic layout techniques, such as floating the elements and setting "overflow" on the parent (or some other method of auto-clearing the floats).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    sdchilderley is offline x10Hosting Member sdchilderley is an unknown quantity at this point
    Join Date
    Dec 2009
    Location
    Peterborough UK
    Posts
    22

    Re: Common Problem

    Thats 2 confusing i think ill just skip it... unless anyone else has anything

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Common Problem

    It's not hard.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Aboutghosts Example</title>
        <link rel="stylesheet" type="text/css" href="css/default.css">
      </head>
      <body>
        <div class="container">
          <div id="Foo" class="contentbox">content box 3</div>
          <div id="Bar" class="contentbox">content box 4</div>
          <div id="Baz" class="contentbox">content box 1</div>
          <div id="Comments"  class="contentbox">
            <p>content box 2</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>Tons of comments here</p>
          </div>
        </div>
      </body>
    </html>
    If you want to give something a unique name, use the "id" attribute, not "class". "Comments" was the only element with an obvious name; the others currently have stand-in names. You want to use something descriptive of what the element is.

    default.css:
    Code:
    .container {
        overflow: auto;
    }
    .contentbox {
        float: right;
    }
    #Foo, #Baz {
        width: 5em;
    }
    #Bar, #Comments {
        width: 10em;
    }
    #Baz {
        clear: both;
    }
    Note the use of ems rather than px.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. A problem with certificate
    By eon01 in forum Free Hosting
    Replies: 1
    Last Post: 07-31-2008, 01:27 PM
  2. DB number problem
    By lionheart8 in forum Free Hosting
    Replies: 5
    Last Post: 04-08-2008, 08:26 AM
  3. Problem uploading image (GD library problem)
    By HyDr@ in forum Free Hosting
    Replies: 1
    Last Post: 12-01-2006, 04:27 PM
  4. Ad code problem!
    By Akkarin in forum Free Hosting
    Replies: 8
    Last Post: 08-29-2005, 10:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers