If the text is longer than one line, it will be truncated and end with an ellipsis ….
overflow: hiddenprevents the text from overflowing its dimensions (for a block, 100% width and auto height).white-space: nowrapprevents the text from exceeding one line in height.text-overflow: ellipsismakes it so that if the text exceeds its dimensions, it will end with an ellipsis.width: 200px;ensures the element has a dimension, to know when to get ellipsis- Only works for single line elements.
 
预览
If I exceed one line’s width, I will be truncated.
HTML
<p class="truncate-text">If I exceed one line's width, I will be truncated.</p>
CSS
.truncate-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 200px;
}