关于css:CSS超出隐藏

2次阅读

共计 811 个字符,预计需要花费 3 分钟才能阅读完成。

一、单行文本

overflow: hidden; 
text-overflow:ellipsis;
white-space: nowrap;

二、多行文本

.c_contM_word {
        position: relative;
        width: 80%;
        max-height: 189px;
        text-overflow: ellipsis;
        background-color: cyan;
        display: -webkit-box;
        -webkit-line-clamp: 6;// 超出 6 行暗藏
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      
      
      // 或者应用伪元素
      .c_contM_word {
        position: relative;
        width: 80%;
        max-height: 189px;
        text-overflow: ellipsis;
        background-color: cyan;
        overflow: hidden;
      }
      .c_contM_word::after {
        content: "...."; // '...'
        position: absolute;
        bottom: 0;
        right: 0;
        padding-left: 40px;// 设置伪元素的 paddingleft 为 40px,已达到遮挡文字效果
        background: -webkit-linear-gradient(left, transparent, #fff 55%);// 设置 padding-left 线性突变色彩~~~~
        background: -o-linear-gradient(right, transparent, #fff 55%);
        background: -moz-linear-gradient(right, transparent, #fff 55%);
        background: linear-gradient(to right, transparent, #fff 55%);
      }
正文完
 0