Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-27-2012, 11:35 PM   PM User | #1
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
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?
Keleth is offline   Reply With Quote
Old 12-27-2012, 11:37 PM   PM User | #2
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
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;
Keleth is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:09 AM.


Advertisement
Log in to turn off these ads.