Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts

    overflow-x:scroll with div children

    hi
    im trying to get a div that is set to scoll on the x axis when it's content is wider than it's width. problem ocurrs when i try to place divs inside the scrollable parent.

    Code:
    <div style="width:100px;overflow-x:scroll;white-space:nowrap;">
    <div style="float:left;">dlsjgklfsgkjdfjgkjkldfsjkgljfkldjglkjdflksjglkfdjklgjlksdfjglkjdlkfjgklfdjlksg</div>
    <div style="float:left;">dlsjgklfsgkjdfjgkjkldfsjkgljfkldjglkjdflksjglkfdjklgjlksdfjglkjdlkfjgklfdjlksg</div>
    <div style="float:left;">dlsjgklfsgkjdfjgkjkldfsjkgljfkldjglkjdflksjglkfdjklgjlksdfjglkjdlkfjgklfdjlksg</div>
    <div style="float:left;">dlsjgklfsgkjdfjgkjkldfsjkgljfkldjglkjdflksjglkfdjklgjlksdfjglkjdlkfjgklfdjlksg</div>
    <div style="float:left;">dlsjgklfsgkjdfjgkjkldfsjkgljfkldjglkjdflksjglkfdjklgjlksdfjglkjdlkfjgklfdjlksg</div>
    <div style="float:left;">dlsjgklfsgkjdfjgkjkldfsjkgljfkldjglkjdflksjglkfdjklgjlksdfjglkjdlkfjgklfdjlksg</div>
    problem is that the divs don't stay on the same line, and the scrolling of the parent div won't occur on the x axis.
    does anyone know if there's a way to achieve this?

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Try setting the inner div elements to display:inline; while removing the float:left; from each of them and see if that works for you.

    That should put them all on one line, but then you'll need to space them out and worry about any possible line-height issues, etc.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    ricmetal (06-30-2011)

  • #3
    New Coder
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts
    awesome.
    thanks.


  •  

    Posting Permissions

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