Grow your CSS skills. Land your dream job.

How to make a sentence stay inline?

  • # May 12, 2010 at 4:17 am

    Hello everyone,

    I have a small box (fixed width and height) with some text in it. It’s great if the string fits in it or if it’s just one word (even if too long), then only the part that fits is visible (using overflow:hidden). The problem is, that if the string is more than one word I would like it to stay on the line and just hide what doesn’t fit without the text going to the other line.

    I hope I made myself clear.
    If not, maybe this will:
    [img]http://img.skitch.com/20100512-g2pdpwpfig9tr39h883etknj62.preview.jpg[/img]
    Live example here: http://ramiai.net/dev/bc/

    Any help would be greatly appreciated!

    # May 12, 2010 at 9:16 am

    The easiest solution that comes to me is to wrap the text in a <p></p>, then set a higher width than the divs’ one.

    # May 12, 2010 at 10:31 am

    Just add

    Code:
    white-space:nowrap;
    # May 12, 2010 at 11:30 am

    Exactly what needed! Thank you so much!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".