Toskan
Toskan

Reputation: 14961

CSS: how to enforce word wrap on an odd situation?

Have a look at this fiddle where it is tried to wrap text in the yellow div without setting its width or the outer divs width - only by using the width of the inner div

Is there something I could do to achieve this?

thanks a lot

Upvotes: 0

Views: 206

Answers (1)

Chris
Chris

Reputation: 26918

Although it doesn't make sense why you wouldn't just set #h's width to 100, you can try this:

#a{
    background-color: grey;
    padding:5px;
    display: table;
}
#b{
    width: 100px !important;
    background-color: orange;
    line-height: 15px;
    padding:5px;
    display: table-cell;
}
#h{
    background-color: yellow;
    line-height: 15px;
    padding:5px;
    display: table-row;
}

I think we can help you more if you tell us why exactly you don't want to define #h's width explicitly, but I hope that this helped anyway.

Upvotes: 1

Related Questions