WordPress CSS - Sidebar Absolute Positioning

Discussion in 'CSS' started by Pacific Web, Sep 13, 2009.

  1. #1
    Individual posts and categories without enough entries are not displaying properly. See the sidebar at the end of the page in the links below.

    I've been told it may be "absolute positioning of the sidebar wrap causing it to position over the container." Any help is appreciated.

    Individual post:
    http://obsessionfitness.com/bowflex...djustable-space-saving-home-gym-free-weights/

    Category page:
    http://obsessionfitness.com/category/equipment-type/weight-resistance-machines/

    Example of category page with enough posts so there's no problem:
    http://obsessionfitness.com/category/exercise-equipment/beachbody-exercise-equipment/
     
    Pacific Web, Sep 13, 2009 IP
  2. Design_Guy

    Design_Guy Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should not need to use absolute positioning..

    Create a <div> around the main content and the sidebar, then use that div for the background.
     
    Design_Guy, Sep 15, 2009 IP
  3. Pacific Web

    Pacific Web Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Do you mean in the index.php file? I'm not exactly sure how to do this. Here's the index.php code. Thanks for your help?

    <?php get_header(); ?>

    <div id="content">

    <div id="blog">

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <div class="blogpost" id="post-<?php the_ID(); ?>">

    <div class="postheader">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <span class="postmeta">
    <?php comments_popup_link('No Comments', '1 Comment', '% Comments','commentslink'); ?> | Category: <?php the_category(', ') ?>

    <br />&nbsp;Published on: <?php the_time('F j, Y') ?>

    </span>
    </div>
    <div class="postbody">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    </div>

    <div class="subpostmeta"><?php comments_popup_link('No Comments', '1 Comment', '% Comments','commentslink'); ?> | Category: <?php the_category(', ') ?> <?php edit_post_link('Edit', '| ', ' '); ?></div>
    </div>

    <?php endwhile; ?>
    <?php get_sidebar(); ?>

    <div class="navigation">
    <div class="alignleft"><h3><?php next_posts_link('&laquo; Next Page of Reviews') ?></h3></div>
    <div class="alignright"><h3><?php previous_posts_link('Previous Page &raquo;') ?></h3></div>
    </div>

    <?php else : ?>

    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>

    <?php endif; ?>

    </div>

    </div>
    <?php get_footer(); ?>
     
    Pacific Web, Sep 16, 2009 IP
  4. myst_dg

    myst_dg Active Member

    Messages:
    224
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #4
    You're wrapping div#sidebarholder into div#blog, I'd rather take div#sidebarholder out of it, wrap div#sidebarholder and div#blog into a div#container.
     
    myst_dg, Sep 18, 2009 IP
  5. Pacific Web

    Pacific Web Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Where is this happening? I see the following code at the start of the sidebar.php file but not sure how it's wrapping.

    <div id="sidebarholder">
    <div id="sidebar">

    I still think this may be a CSS issue. I hope someone can help...I really need to get this fixed. Thanks.
     
    Pacific Web, Sep 18, 2009 IP
  6. Pacific Web

    Pacific Web Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I took out the absolute positioning in Layout.CSS. It fixed the problem but removed the sidebar completely on other pages. Anyone have suggestions? Thanks.
     
    Pacific Web, Sep 20, 2009 IP
  7. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi,

    You need to set a min-height for all your content, so regardless of the page size it has a minimum height (the height of the sidebar)

    In fact it's already sort of implemented, but just with an incorrect height, open layout.css and find:

    
    #blog {
    float: left;
    [B]min-height:1050px;[/B]
    }
    
    Code (markup):
    Change the min-height so it's enough to hold the content of the sidebar, doing some quick tests about 2400px seems ok, so:

    
    #blog {
    float: left;
    [B]min-height:2400px;[/B]
    }
    
    Code (markup):
     
    wd_2k6, Sep 23, 2009 IP
  8. Pacific Web

    Pacific Web Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Finally, someone who was able to help! That worked, thanks so much. Reputation bumped.
     
    Pacific Web, Sep 23, 2009 IP
  9. Aidey

    Aidey Member

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #9
    glad you got it sorted. absolute positioning in css is dodgy in browsers, doesnt display correctly in most.
     
    Aidey, Sep 23, 2009 IP
  10. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #10
    Still breaks on large fonts/120dpi systems - which is why you shouldn't be using absolute positioning to make your sidebar in the first damned place. That's float's job. You leave it as is, next time you go in and change the content of the sidebar it will just screw up again.
     
    deathshadow, Sep 28, 2009 IP