Centered Div Worked a few days ago. Doesn't work now

Discussion in 'Web Design and Development' started by sbryan, Sep 16, 2009.

  1. sbryan macrumors member

    Jun 6, 2007
    In IE, Firefox, or Safari... and I can't figure it out.

    Here's the HTML code:

    		<div id="contentpane">
        	<div id="nav">
        	<div id="NavButtons">
            <?php include_once "header.php"; ?>
        	</div><!-- End of NavButtons -->
    </div><!-- End of Nav -->
        <div id="headerimage"></div>
      	<div id="content_frame_header"><p><?php echo date('l F jS\, Y'); ?></p></div>
        <div id="content_frame">
        <div id="leftside">
        <?php query_posts("showposts=3&orderby=date&order=DESC"); ?>
                    <?php if (have_posts()) : ?>
                    <?php while (have_posts()) : the_post();?>
                    <span class="home_post_title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span>
                    <div id="byline">
                    <span class="home_post_date"><?php the_time('F jS, Y'); ?></span>
    				<span class="home_post_brand">Brand: <?php the_category(',') ?></span></div> <!-- End of Byline Containing Div -->
                    <span class="home_post_image"><?php the_attached_image('medium'); ?></span>
                    <span class="home_post_text"><?php the_excerpt(); ?></span>
                    <span class="home_post_keyword"><?php the_tags(); ?></span>
                    <span class="home_post_morebutton"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">more...</a></span>
                    <?php endwhile; ?>
                    <?php else : ?>
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php endif; ?>
        </div><!-- End of Left Side -->
        <div id="rightside">
        <?php include_once "sidebar.php"; ?>
        </div><!-- End of Right Side -->
        </div><!-- End of Content Frame -->
        <div id="footer"></div>
    </div><!-- End of Content Pane -->
    Here's the CSS:

    body {
    	line-height: 1;
    	background-image: url(../images/backgroundx.jpg);
    	background-repeat: repeat-x;
    #contentpane {
    	margin-left: auto;
    	margin-right: auto;
    	width: 950px;
    	height: auto;
    	background: none;
    I've used a centered, nested div on practically every website I've ever made, and I can't understand why this particular website failed to center in every browser overnight when it had worked before.
  2. jeremy.king macrumors 603


    Jul 23, 2002
    Fuquay Varina, NC
  3. sbryan thread starter macrumors member

    Jun 6, 2007
    Ran it through a validator. There were many errors, but nearly all of them pertained to META elements and not to positioning.

    As far as those includes, everything is constricted to fit within #contentpane. All elements are where they should be within #contentpane, but #contentpane isn't centering.
  4. angelwatt Moderator emeritus


    Aug 16, 2005
    Of the code you provided it looks fine. It could be that the #contentpane CSS is being overwritten in another area of the CSS. One thing to help debug is to use the Firebug addon on Firefox and select #contentpane and see what CSS is getting applied to it.
  5. sbryan thread starter macrumors member

    Jun 6, 2007
    Excellent recommendation Angelwatt, Firebug is a powerful tool.

    Turns out, I had three CSS stylesheet references. One was local, one was on the production side, and one was on the client side (future home).

    One of them was out of sync.

    So I just nixed the two references not related to what I was doing and it works.

Share This Page