WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Site Design > Graphics & Design Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Graphics & Design Discussion Forum Post your graphics design questions/comments/ideas in here. Ask questions, post tutorials, discuss trends and best practices. Sub-forum for website accessibility and usability.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-14-2007, 12:33 PM
thindenim's Avatar
thindenim thindenim is offline
WebProWorld Pro
 

Join Date: Jan 2007
Location: Scotland
Posts: 238
thindenim RepRank 1
Default Wrapping on Horizontal CSS Menu

Hi there,

I have a subnav bar on my site, which is a horizontal css list menu. Problem I have is that if the menu items go wider than the page it wraps down to the next line. This is what I want it do (I don't want nowrap), however, it cuts off items in the middle, i.e. on this page: -

Hair Products

The "Curling Tongs" menu item starts on the first line and finishes on the second. Does anyone know any way round this? What I after is if a full <li> doesn't fit, then it goes onto the next line. Quite hard to explain, but hopefully you get the idea!


Thanks,
David
__________________
Girlz Night - professional hair and beauty products
Web design glasgow - from Thin Denim
Reply With Quote
  #2 (permalink)  
Old 11-14-2007, 05:37 PM
tw tw is offline
WebProWorld New Member
 

Join Date: Mar 2004
Location: Atlanta
Posts: 8
tw RepRank 0
Default Re: Wrapping on Horizontal CSS Menu

Set the a element to display: block, e.g.:

#subnavbar li a {
display: block;
}
__________________
_._._._
t w
Reply With Quote
  #3 (permalink)  
Old 11-15-2007, 05:23 AM
thindenim's Avatar
thindenim thindenim is offline
WebProWorld Pro
 

Join Date: Jan 2007
Location: Scotland
Posts: 238
thindenim RepRank 1
Default Re: Wrapping on Horizontal CSS Menu

Unfortunately that doesn't do the trick as the display is already set to inline. If it's set to display:block all the links go underneath each other.
__________________
Girlz Night - professional hair and beauty products
Web design glasgow - from Thin Denim
Reply With Quote
  #4 (permalink)  
Old 11-15-2007, 10:54 AM
jannmirch's Avatar
jannmirch jannmirch is offline
WebProWorld Member
 

Join Date: Sep 2005
Location: Yorktown Heights, NY
Posts: 75
jannmirch RepRank 0
Default Re: Wrapping on Horizontal CSS Menu

Someone else, with more smarts than me may be able to tell you a way to control it with CSS, but rather than beating your head against a wall in the meantime, set up a second list under the first so you can manually control the line break.
__________________
Graphic & Web Design
www.jannmirch.com
Reply With Quote
  #5 (permalink)  
Old 11-15-2007, 11:07 AM
tw tw is offline
WebProWorld New Member
 

Join Date: Mar 2004
Location: Atlanta
Posts: 8
tw RepRank 0
Default Re: Wrapping on Horizontal CSS Menu

Quote:
Originally Posted by thindenim View Post
Unfortunately that doesn't do the trick as the display is already set to inline. If it's set to display:block all the links go underneath each other.
No, you've set the <li> to display inline. Set the <a> to display: block and keep the <li> inline.
__________________
_._._._
t w
Reply With Quote
  #6 (permalink)  
Old 11-15-2007, 11:25 AM
iany iany is offline
WebProWorld Pro
 

Join Date: Sep 2003
Location: Stirling, Scotland
Posts: 204
iany RepRank 1
Default Re: Wrapping on Horizontal CSS Menu

Hi thindenim

Couple of things. You won't be able to do this as you suggest in CSS. However, two things could help. Specify the width of the <li> element in the subnav div. As you know the width of the subnav you can work out the number that can be accommodated in that width. Remember to add the padding and margins to the overall. In that way you will force any extra <li> into the next line.

Couple of other points while we are on the subject.

You haven't specified a background colour in the body code. Always good idea as not every one uses the default colours in their browsers. Also you have a non-valid style element at line377 .RecentlyViewed_Txt - vertical align not recognised.

You might also want to run your html through a validator - as round there is a missing <ul></ul>, I think after the subnavbar div.

If you want to discuss further, send me a PM and we can chat tomorrow (friday)

Regards

Ian
__________________
Ian Young
http://www.iyesolutions.co.uk
Reply With Quote
  #7 (permalink)  
Old 11-15-2007, 11:58 AM
thindenim's Avatar
thindenim thindenim is offline
WebProWorld Pro
 

Join Date: Jan 2007
Location: Scotland
Posts: 238
thindenim RepRank 1
Default Re: Wrapping on Horizontal CSS Menu

Hi TW, unforfunately that doesn't do the trick either

I may just break the list apart. It's a database loop so will need to split that up into an outer and inner loop or something

Will check the code Ian, thanks.
__________________
Girlz Night - professional hair and beauty products
Web design glasgow - from Thin Denim
Reply With Quote
  #8 (permalink)  
Old 11-15-2007, 12:36 PM
holyhttp holyhttp is offline
WebProWorld Member
 

Join Date: Jul 2006
Location: Oakland, CA
Posts: 45
holyhttp RepRank 0
Default Re: Wrapping on Horizontal CSS Menu

You can wrap your navigation menu by just floating the list item instead of having them inline:
#subnavbar li {
float:left;
margin-right:5px;
background-image:url(../i/layout/arrow_pink.gif);
background-repeat:no-repeat;
background-position:center left;
padding-left:14px;
line-height:18px;
}

because li is now floated it might be a good idea to specify the height of #subnavbar. A height 36px should be enough to contains the 2 lines i.e double of the <li> line-height.

Last edited by holyhttp : 11-15-2007 at 12:40 PM.
Reply With Quote
  #9 (permalink)  
Old 11-15-2007, 01:15 PM
iany iany is offline
WebProWorld Pro
 

Join Date: Sep 2003
Location: Stirling, Scotland
Posts: 204
iany RepRank 1
Default Re: Wrapping on Horizontal CSS Menu

Quote:
Originally Posted by holyhttp View Post
You can wrap your navigation menu by just floating the list item instead of having them inline:
Don't you still require to have display:inline with the float to prevent IE6 doubling the left margin?

See :
IE Doubled Float-Margin Bug - CSS fixes and workarounds

Ian
__________________
Ian Young
http://www.iyesolutions.co.uk
Reply With Quote
  #10 (permalink)  
Old 11-18-2007, 08:45 PM
weegillis weegillis is offline
WebProWorld Pro
 

Join Date: Oct 2003
Location: Alberta, Canada
Posts: 222
weegillis RepRank 1
Default Re: Wrapping on Horizontal CSS Menu

You may be making an issue of something that is very minor, cosmetically. Even with wrapping, your link retains its integrity. What's more, if you solve the issue at the current font size, it may simply re-appear when text size is adjusted.

If you don't want link phrases to wrap, use the old standby: the non-breaking space,
Code:
&nbsp;
within the phrase. Then the entire link phrase will drop to the next line.
__________________
Volunteer for something in your community today!
Reply With Quote
  #11 (permalink)  
Old 11-19-2007, 04:41 AM
iany iany is offline
WebProWorld Pro
 

Join Date: Sep 2003
Location: Stirling, Scotland
Posts: 204
iany RepRank 1
Default Re: Wrapping on Horizontal CSS Menu

thindenim

As I mentioned earlier, specifying the width of the subnavbar li helps with this situation.

See IY e-solutions -girlznight test

where I have mocked up the menu. Style info is at top of page.
Two additions to your style (and addition of wrapping <u></ul>)

Using float:left does not work in FireFox as you need to specify the height of subnavbar <u>. Unfortunately, this also limits the number of menu items that you could have, unlike your option which would, if you wished allow a third layer.

Cheers

Ian
__________________
Ian Young
http://www.iyesolutions.co.uk
Reply With Quote
Reply

  WebProWorld > Site Design > Graphics & Design Discussion Forum


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
text wrapping around images mbeckhardt Graphics & Design Discussion Forum 2 06-22-2007 02:19 PM
Trying to accomplish word wrapping lewatson Graphics & Design Discussion Forum 5 03-31-2005 10:57 AM
Right-aligned images/divs and text wrapping ADAM Web Design Graphics & Design Discussion Forum 3 12-02-2004 02:04 PM
horizontal css menu ozchris Graphics & Design Discussion Forum 2 11-09-2004 07:34 PM
Horizontal Scrolling wealth42 WebProWorld: Guidelines/Announcements/Suggestions 5 02-28-2004 10:58 PM


Search Engine Friendly URLs by vBSEO 3.0.0