SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    May 2005
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto height for unordered list?

    I'm working on a template that has a sidebar breadcrumb navigation, which is an unordered list. The <ul> is automatically assigned an ID (#breadcrumb) and the css has a fixed height for this ID. This <ul> is not in its own div.

    Is it possible to not have a fixed height for the <ul> tag, but instead have the height automatically expand as more content is added to the list? Or is the only way to do this is to wrap the <ul> in a div?

    Thank you,
    Ron

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,893
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    The best plan is just not to set a height on #breadcrumb, and it will automatically take up whatever size it needs to fit the contents. There's no need to worry about whether it's in a <div> or not – you can apply pretty much the same CSS to any block elements as you can to a <div>.

  3. #3
    SitePoint Zealot
    Join Date
    May 2005
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've tried that, removing the height from the css and it just collapses behind the <ul> "content". I forgot to mention that the #breadcrumb has a background color, so it's easy to see that the height collapses and the height doesn't expand to fit the content.

  4. #4
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,893
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Are the <li>s inside the <ul> floated? If so, add overflow:hidden; to #breadcrumb.

    Failing that, if you give us a link to the page then we can see what is really going on!

  5. #5
    SitePoint Zealot
    Join Date
    May 2005
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That worked!!!
    Thank you Stevie!


Bookmarks

Posting Permissions

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