I want to have all text be ending with '...' but it only works for the inner div:
div {
border: solid 2px blue;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 40px;
}
<div>Test test test test test test
<div>asdasdasdasdasd</div>
</div>
http://jsfiddle.net/JU8Up/
is there any Solution so that also the text contained in the outer div gets the '...' ?
edit: seems like its a chrome problem, but still the fix in the answer below works
If your text-overflow is not working you must ensure display, overflow and white-space CSS properties are set to proper values. Ellipsis works in the same way on all types of elements. But you need to use it with caution on Flex, CSS Grid or on a Table.
Inline overflow occurs when the text in a line overflows the available width without a breaking opportunity. To force overflow to occur and ellipses to be applied, the author must apply the nowrap value to the white-space property on the element, or wrap the content in a <NOBR> tag.
A text-overflow property in CSS is used to specify that some text has overflown and hidden from view. The white-space property must be set to nowrap and the overflow property must be set to hidden. The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string.
It works by adding float: left;
to the div CSS, but without any further context I can't comment on what side-effects that may have in your implementation.
Example here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With