• Resolved cbmark

    (@cbmark)


    Hi all, im tearing my hair out over this and hope you guys can help spot something im missing. I am trying to float the sidebar right and inline with content on the left just a nice simple layout however floating the sidebar right is pushing it right but below the content. Now I know this is usually a size issue but I have check all the sizes and reduced the sidebar to a really small size but nothing is working.

    Site: http://marksblog.co.uk
    CSS: http://marksblog.co.uk/wp-content/themes/mb/style.css

    Any ideas?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Get rid clear:left; div between the content and the sidebar.

    Thread Starter cbmark

    (@cbmark)

    Hiya esmi I have removed it which has moved the sidebar which is great just a problem with the container not expanding down now any ideas? I have updated the site so you can see what’s happening.

    Mark

    Try adding a clear:both; just before the footer. Or use something like:

    #container:after {
        content: ".";
        display: block;
        height: 0;
        clear: both;
        visibility: hidden;
    }
    Thread Starter cbmark

    (@cbmark)

    Wow, cheers so much just placed that code in works a treat! Thanks so much esmi! Can I ask a stupid question though what exactly is this doing Im assuming its adding a div after container with a content of . clearing it and hiding it? Just wondering how on earth does that fix it?

    Mark

    It’s not actually adding anything to the markup. It’s making use of a pseudo CSS selector :after. This selector (which is similar to the more common :hover selector) allows you style whatever comes immediately after your chosen element (in this case, the container block). We then use another trick – CSS generated content – which allows us to display pure CSS content (usually just a few characters).

    So we use CSS to add a single full stop character after the container div. We make sure that this CSS content is displayed as a block level element so it can be used to clear any remaining floats. Then we hide it.

    End result – the container div is drawn down below any other floated elements inside it.

    Thread Starter cbmark

    (@cbmark)

    Nice! Shall try and store that in memory (and bookmark this) for future reference! Thanks for the explanation too, amazing what little tricks there are!

    Thanks esmi + rep (if only there was a plus rep button!)

    Mark

    No problem 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Sidebar is not floating right correctly.’ is closed to new replies.