Why are my results staggered?

Discussion in 'CSS' started by Crash-test dummy, Jan 24, 2007.

  1. #1
    I have been developing this site and find that when a new result is added it layers it as it should but then indents it more than the previous result. The following result is even more indented.

    Here's the link if you want to see what I'm talking about:
    http://blog-directory.gardeningtipsnideas.com/php/display_blogs.php?action=display&id=Austin

    and here's the css code I have for this .div element;

    #displayBlog-inner {
    display: block;
    width: 700px;
    padding: 0;
    margin: 25px 0 15px;
    text-align: left;
    }
     
    Crash-test dummy, Jan 24, 2007 IP
  2. audax

    audax Peon

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try adding this:

    
    #bodyarea .mapbground{
    padding: 0;
    clear: both;
    }
    Code (markup):
    to the stylesheet.
     
    audax, Jan 25, 2007 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    It appears that this,
    
    <div id="bodyarea" class="mapbground">
    Code (markup):
    is not closed and every iteration nests deeper. Assuming a template, either you've got that within a loop section or, it's just not closed each iteration. I suspect the former, as you have an id on it indicating it's a one-off. Not to mention it seems more logical. :)

    If you'll run a copy of your server output through Tidy[1], to pretty print it, nesting levels become more obvious.

    cheers,

    gary

    [1] I just use the Tidy/validation extension for Firefox in Windows. In Linux, I just use the Tidy utility from the cli.
     
    kk5st, Jan 25, 2007 IP
  4. Crash-test dummy

    Crash-test dummy Peon

    Messages:
    61
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Crash-test dummy, Jan 25, 2007 IP
  5. Anduril66

    Anduril66 Well-Known Member

    Messages:
    390
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    108
    #5
    I think its from:
    #bodyarea {
    padding: 10px;
    min-height: 300px;
    }

    Each of your 3 blog descriptions is in its own <div id="bodyarea" class="mapbground"></div> which is unnecessary and semantically incorrect (there should only be one instance of a block with a given id per page, if there is more than one you should use class to describe). Any ways, I think you only need one <div id="bodyarea" class="mapbground">, move one "<script language="JavaScript" src="http://blog-directory.gardeningtipsnideas.com/javascript/localBlog.js">
    </script>" into the bodyarea div and delete the rest, and move the "displayBlog-inner" divs into the bodyarea div. The bodyarea div is meant to be a container for all of the main content and does not need to be repeated.
     
    Anduril66, Jan 25, 2007 IP
    kk5st likes this.
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    Because you've told it to be that tall.
    
    #bodyarea {     /*(line 58)*/
        padding: 20px;
        min-height: 300px;
        }
    Code (markup):
    If you're trying to ensure the float is enclosed, do
    
    #bodyarea {
        padding: 20px;
        overflow: hidden;
        }
    Code (markup):
    See Enclosing Float Elements for an explanation and a fix or two for IE.

    Your DTD is long obsolete. The current standard is html 4.01. Use this DTD;
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    Code (markup):
    The proper, complete DTD will trigger standards mode in IE. It will try, to its limited ability, to follow the rules.

    //edit: crossed with Anduril66
    //note to self: must type faster

    cheers,

    gary
     
    kk5st, Jan 25, 2007 IP
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    Anduril66 is right. You closed the bodyarea, but you left it inside the loop. Your tpl file probably looks something like this (Smarty templating syntax):
    
    {section name=entry loop=$entries}
    <div id="bodyarea>
      <div id="displayBlog-inner"
    {section name=pic loop=$pics}
        <div id="displayBlog-pic">
          <img src="{$pics[entry]}">
        </div>
    {/section}
        <p>{$entries[entry]}</p>
      </div>
    </div>
    {/section}
    Code (markup):
    The bodyarea needs to be outside the loops.
    
    <div id="bodyarea>
    {section name=entry loop=$entries}
      <div id="displayBlog-inner"
    {section name=pic loop=$pics}
        <div id="displayBlog-pic">
          <img src="{$pics[entry]">
        </div>
    {/section}
        <p>{$entries[entry]}</p>
      </div>
    {/section}
    </div>
    Code (markup):
    The float enclosing then belongs on "displayBlog-inner" since it is the parent of the float image.

    cheers,

    gary
     
    kk5st, Jan 25, 2007 IP
  8. Crash-test dummy

    Crash-test dummy Peon

    Messages:
    61
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks both of you for your awesome help. Not only has your suggestions worked but I learnt something new as well. Cheers...
     
    Crash-test dummy, Jan 27, 2007 IP