If you want to restrict it to one line, use white-space: nowrap;
on the div.
If you want to indicate that there's still more content available in that div, you may probably want to show the "ellipsis":
text-overflow: ellipsis;
This should be in addition to white-space: nowrap;
suggested by Septnuits.
Also, make sure you checkout this thread to handle this in Firefox.
You can use this css code:
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
The text-overflow property in CSS deals with situations where text is clipped when it overflows the element's box. It can be clipped (i.e. cut off, hidden), display an ellipsis ('…', Unicode Range Value U+2026).
Note that text-overflow only occurs when the container's overflow property has the value hidden, scroll or auto and white-space: nowrap;.
Text overflow can only happen on block or inline-block level elements, because the element needs to have a width in order to be overflow-ed. The overflow happens in the direction as determined by the direction property or related attributes.
the best code for UX and UI is
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
display: inherit;
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