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 2 of 2
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts

    Giving absolute positioned items an auto width

    I made a simple drop down menu, eg mouse over an item and a list of items drops down from it.

    I wrote some Javascript (jQuery) that gives the item that drops down (a ul) a min-width equal to the link it comes from. The problem I'm having is that the dropdown's content is auto generated, can be multiword, and is often longer then the width of the parent. Because its absolutely positioned, it doesn't get wider though; it sticks to the min width. So I have some items that are going multi-line and it looks weird.

    I'm wondering if anyone knows how to get an absolutely positioned item to get an auto width (if this makes sense), or knows a Javascript trick I could use to do it?

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    So I just did yet another google search with slightly different terms and came up with the super easy and working solution:

    CSS- white-space: nowrap;


  •  

    Posting Permissions

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