9

I am wondering why with markup like

http://jsfiddle.net/rkEpx/

I get

As you can see, the 1st and last menu items have its link broken into 3 lines even tho theres enough space to expand. Is it possible to have the line not break unless theres really no space? If possible without setting a fixed width or using non-breaking spaces?

1
  • Works fine in Opera 11 and IE8. Might be a Firefox bug. Commented Jan 7, 2011 at 16:43

3 Answers 3

3

  HTML entity or white-space: nowrap; CSS. But it won't break even if there is really no space.

You can try using display: inline-block; instead of float: left; for your li, img and / or p.

http://jsfiddle.net/2Mv2E/

Sign up to request clarification or add additional context in comments.

2 Comments

display: inline-block; doesn't work IE7 or IE6. You would have to use *li { display: inline; } for those browsers to work.
white-space: nowrap is not good with when I add max-width the text don't wrap causing the layout to break jsfiddle.net/2Mv2E/1
1

Try adding:

li {
    padding: 0;
    margin: 0 3px 0 0;
    float: left;  
    max-width: 120px;
white-space: nowrap;
}

Comments

1

I have no idea why it is behaving like that, but it seems you can fix it by floating the p's as well:

p {
  float: left;
}

Depending on your browser requirements, you can also choose to just float the p right after the image:

img + p {
  float: left;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.