zoukankan      html  css  js  c++  java
  • css 超出部分显示省略号 汇总

    单行: 加宽度

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

    多行:

    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;

    兼容移动端

    p{position: relative; line-height: 20px; max-height: 40px;overflow: hidden;} p::after{content: "..."; position: absolute; bottom: 0; right: 0; padding-left: 40px; background: -webkit-linear-gradient(left, transparent, #fff 55%); background: -o-linear-gradient(right, transparent, #fff 55%); background: -moz-linear-gradient(right, transparent, #fff 55%); background: linear-gradient(to right, transparent, #fff 55%); }

    注:

    1. 将height设置为line-height的整数倍,防止超出的文字露出。
    2. 给p::after添加渐变背景可避免文字只显示一半。
    3. 由于ie6-7不显示content内容,所以要添加标签兼容ie6-7(如:<span>…<span/>);兼容ie8需要将::after替换成:after。
  • 相关阅读:
    (4.24~4.30)
    (4.17~4.23)
    (4.10~4.16)
    FFT题集
    kd树的构造与搜索
    schtasks命令
    关于[WinError 10054] 远程主机强迫关闭了一个现有的连接。
    数据去重复
    将ppt文档转换成pdf
    mvc上传
  • 原文地址:https://www.cnblogs.com/zhi-ming/p/10453170.html
Copyright © 2011-2022 走看看