css文本溢出 html悬浮显示文本

2023-01-27  本文已影响0人  简小园

文本溢出

.textOverflow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
}

文本多行溢出

.textOverflowMultiline {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; // 显示行数
}

.textOverflowMulti(@line: 3, @bg: #fff) {
  position: relative;
  max-height: @line * 1.5em;
  margin-right: -1em;
  padding-right: 1em;
  overflow: hidden;
  line-height: 1.5em;
  text-align: justify;
  &::before {
    position: absolute;
    right: 14px;
    bottom: 0;
    padding: 0 1px;
    background: @bg;
    content: '...';
  }
}

悬浮显示文本信息

给标签添加 title 属性,如下图:

文本悬浮显示
上一篇下一篇

猜你喜欢

热点阅读