I have a div
element which contains some text. This element has fixed width. If the text is so long that it cannot fit in one line, I want to hide that text (the wh
white-space: nowrap
to prevent line breaks.overflow: hidden
, and set the same value to height
and line-height
..outer-wrapper {
overflow: hidden;
height: 1.2em;
line-height: 1.2em;
border: 1px dotted black;
margin: 1em;
}
.outer-wrapper::before {
content: '';
display: inline-block;
}
.inner-wrapper {
display: inline-block;
white-space: nowrap;
}
this is a short line
this is a super long line of text that it is never ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever going to fit on a single line!