Grow your CSS skills. Land your dream job.

Help text width!

  • # January 17, 2012 at 8:18 am

    I can’t figure this out..

    I have a simple text and I want to make it centered inside a div with a maximum width (200px). I have display:block and width:200px .
    The text is appearing centered until it reaches the 200px and then it continues in the same line, there’s no break.

    Any idea what I’m doing wrong?

    # January 17, 2012 at 8:21 am

    Why don’t you create a jsfiddle of the problem?

    # January 17, 2012 at 9:22 am

    I would but jsfiddle gives me the correct result:

    http://jsfiddle.net/L6TrY/

    # January 17, 2012 at 9:25 am

    LMAO… I have no idea why, but this is making me laugh hysterically

    I would but jsfiddle gives me the correct result:

    # January 17, 2012 at 9:39 am

    Well It’s true. This is something that should be easy to implement. For some reason this isn’t working, so maybe someone could have a clue why I’m seeing a different behavior.
    I don’t know what’s funny about that.

    # January 17, 2012 at 9:43 am

    Ok, I know what’s the problem with my jsfiddle example.

    This is the problem:
    http://jsfiddle.net/L6TrY/5/

    If I have a unique bigger word it continues after the 200px width.

    # January 17, 2012 at 9:47 am

    Solved. overflow: hidden;

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

You must be logged in to reply to this topic.

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