关于css:CSS超出隐藏

一、单行文本

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%);
      }

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理