css multiline overflow... single line centered

css multi-line overflow... single-line centered style processing

Many projects encounter multi-line overflow and become... , and the processing style is:

Modify -webkit-line-clamp to a few lines of overflow

.css{
    
    
  overflow : hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

If the item needs to be centered on a single line, multi-line overflow ellipsis is handled as follows:

insert image description here

Label:

<div className='title'>
  <div className='text'>
    视频容内容内容视频容内容内容视频容内容内容视频容内容内容视频容内容内容视频容内容内容
  </div>
</div>

css style:

.title {
    
    
  height: 90px;
  padding: 10px 20px;
  display: flex;
  justify-content: center;
  align-items: center;

  .text {
    
    
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;

    font-size: 28px;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.85);
    line-height: 40px;
  }
}

The case comes from the react project using the less + postcss plug-in, for reference, there are slight differences, but they are all the same.

It is recommended to use flex layout, which is simple and direct. Since a single line is centered and multiple lines overflow..., there is no way to solve it with one label. The case comes from an actual project, please leave a message if you have any questions

Guess you like

Origin blog.csdn.net/weixin_44461275/article/details/124639782