Submit Your Article Forum Rules

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Wrapping on Horizontal CSS Menu

  1. #1
    Senior Member thindenim's Avatar
    Join Date
    Jan 2007
    Posts
    269

    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

  2. #2
    Junior Member
    Join Date
    Mar 2004
    Posts
    12

    Re: Wrapping on Horizontal CSS Menu

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

    #subnavbar li a {
    display: block;
    }

  3. #3
    Senior Member thindenim's Avatar
    Join Date
    Jan 2007
    Posts
    269

    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.

  4. #4
    Senior Member jannmirch's Avatar
    Join Date
    Sep 2005
    Posts
    229

    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.
    Marketing & Web Design www.WestchesterMarketingCafe.com
    Twitter: @JannMirch
    FB: Marketing Cafe

  5. #5
    Junior Member
    Join Date
    Mar 2004
    Posts
    12

    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.

  6. #6
    Senior Member iany's Avatar
    Join Date
    Sep 2003
    Location
    Stirling, Scotland
    Posts
    339

    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

  7. #7
    Senior Member thindenim's Avatar
    Join Date
    Jan 2007
    Posts
    269

    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.

  8. #8

    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.

  9. #9
    Senior Member iany's Avatar
    Join Date
    Sep 2003
    Location
    Stirling, Scotland
    Posts
    339

    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

  10. #10
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,785

    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.

Page 1 of 2 12 LastLast

Similar Threads

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

Posting Permissions

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