dcsimg
www.webdeveloper.com
Results 1 to 7 of 7

Thread: Why won't you float!?

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    USA
    Posts
    352

    Question Why won't you float!?

    http://sandbox.willpracht.net/

    I decided to swallow my pride and post this on here.

    The main box in the middle (#body-container) should have many .post-container's in it, all floated left so that it scrolls horizontally and not vertically at all.

    I've floated the .post-container's, set the width on #body-container to auto.
    It doesn't want to work.
    I'm not sure why .

    I've tried looking at it thru Firebug. It looks like .post-container's are being floated, just stacking on top of each other anyway.

    If anyone can help, that'd be greatly appreciated.

    Thank you very much,
    Will

  2. #2
    Join Date
    Jul 2009
    Posts
    91
    Doesn't width:auto work based on the browser window width? I assume you were hoping that the floated elements would make the page grow wider? Float only floats up to the page/container limits.

    If the posts are created dynamically you could position them absolutely with left: values to allow for those which came before. I'm sure there is a better way though. I'll leave it to someone else to point out why you should never have horizontal scrolling though because I don't agree as you can see from an old semi-abandoned project of mine!

  3. #3
    Join Date
    Jan 2005
    Location
    USA
    Posts
    352
    Quote Originally Posted by DaiLaughing View Post
    Doesn't width:auto work based on the browser window width? I assume you were hoping that the floated elements would make the page grow wider? Float only floats up to the page/container limits.

    If the posts are created dynamically you could position them absolutely with left: values to allow for those which came before. I'm sure there is a better way though. I'll leave it to someone else to point out why you should never have horizontal scrolling though because I don't agree as you can see from an old semi-abandoned project of mine!
    width: auto is based on the child elements. The parent expands to fit those child elements.

    I am wanting the floated elements to make the parent grow wider. So, #body-container should expand according to how many .post-container's there are.

    If I did absolute positioning, each .post-container will be at left: 0, mixing together. Not what I want.

  4. #4
    Join Date
    Jul 2009
    Posts
    91
    That's why I asked if the page was dynamic. The scripting would then set each left: to allow for the existing elements. As I said float will not make the container grow wider as far as I know.

    If the page is not dynamic then you could manually set the left:

  5. #5
    Join Date
    Jan 2005
    Location
    USA
    Posts
    352
    The page is dynamic.

    I see what you're getting at... I would like to steer away from absolute positioning. I suppose it would work, but I know that floating works as well...just not working at the moment for some reason.

  6. #6
    Join Date
    Jan 2005
    Location
    USA
    Posts
    352
    Alright, I give up. Absolute positioning it is .

    Thanks for your help .

  7. #7
    Join Date
    Jul 2009
    Posts
    91
    I have fiddled with it and the only other way I can see (and this might be better) is to...

    Get the number of posts from the database (assuming they are fixed width). Set the width of the containing div to that number multiplied by the width (plus any padding, border and margin). Then everything should float off the side of the page.

    No absolutes - any better?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles