火狐浏览器-webkit-line-clamp兼容问题

  • 问题描述:
    firefox68及68以上版本支持-webkit-line-clamp属性
  • 兼容firefox各个版本方案 :

如果某个元素同时存在line-clamp和other-line-clamp两个类,那么other-line-clamp中一定要增加:

display: block !important;

/*chrome 浏览器实现 ...*/
.line-clamp {
    overflow: hidden; /** 隐藏超出的内容 **/
    word-break: break-all;
    text-overflow: ellipsis; /** 多行 **/
    display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
    -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
    -webkit-line-clamp: 2; /** 显示的行数 **/
    box-sizing: border-box;
}

/* 非chrome 实现...*/
.other-line-clamp {
    position: relative;
    display: block !important;
    font-size: 16px;
    line-height: 23px;
    overflow: hidden;
    box-sizing: border-box;
}

/* 占位*/
.other-line-clamp::before {
    content: "";
    float: left;
    width: 30px;
    height: 100%;
    box-sizing: border-box;
}

/* 内容部分*/
.other-line-clamp .fd-line-clamp-text {
    position: relative;
    z-index: 1;
    float: right;
    margin-left: -30px;
    width: 100%;
    min-height: 23px;
    box-sizing: border-box;
}

/* ... 占位*/
.other-line-clamp::after {
    content: "\02026";
    float: right;
    position: relative;
    left: 100%;
    z-index: 2;
    margin-top: 0;
    padding-left: 10px;
    width: 30px;
    height: 23px;
    font-size: 16px;
    box-sizing: border-box;
    font-family: "Avenir", Helvetica, Arial, sans-serif;
    transform: translate(-100%, -100%);
    background: linear-gradient(to left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 20%, rgba(255, 255, 255, 1) 100%);
    background: -ms-linear-gradient(to left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 20%, rgba(255, 255, 255, 1) 100%);
}

下面是实例↓

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="form-table-line-clamp other-line-clamp" style="height: 46px;" data-ellipsis="true">
    <span class="table-td-text line-clamp-text">一旦使用new关键一旦使用new关键字为数组分配了内存空间字为数组分配了内存空间</span>
</div>
</body>
</html>
.form-table-line-clamp {
    width: 200px;
    font-size: 16px;
    line-height: 20px;
    border: 1px solid #000;
    box-sizing: border-box;
}

/*chrome 浏览器实现 ...*/
.line-clamp {
    overflow: hidden !important; /** 隐藏超出的内容 **/
    word-break: break-all;
    text-overflow: ellipsis !important; /** 多行 **/
    display: -webkit-box !important; /** 对象作为伸缩盒子模型显示 **/
    -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
    -webkit-line-clamp: 2; /** 显示的行数 **/
    box-sizing: border-box;
}

/*// 非chrome 实现...*/
.other-line-clamp {
    position: relative;
    display: block !important;
    font-size: 16px;
    line-height: 23px;
    overflow: hidden;
    box-sizing: border-box;
}

/*// 占位*/
.other-line-clamp::before {
    content: "";
    float: left;
    width: 30px;
    height: 100%;
    box-sizing: border-box;
}

/*// 内容部分*/
.other-line-clamp .line-clamp-text {
    position: relative;
    z-index: 1;
    float: right;
    margin-left: -30px;
    width: 100%;
    min-height: 23px;
    box-sizing: border-box;
}

/*// ... 占位*/
.other-line-clamp::after {
    content: "\02026";
    float: right;
    position: relative;
    left: 100%;
    z-index: 2;
    margin-top: 0;
    padding-left: 10px;
    width: 30px;
    height: 23px;
    font-size: 16px;
    box-sizing: border-box;
    font-family: "Avenir", Helvetica, Arial, sans-serif;
    transform: translate(-100%, -100%);
    background: linear-gradient(to left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 20%, rgba(255, 255, 255, 1) 100%);
    background: -ms-linear-gradient(to left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 20%, rgba(255, 255, 255, 1) 100%);
}
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值