首页 > 代码库 > 文本超出用...代替(兼容)

文本超出用...代替(兼容)

div{
    width: 100px;
    height: 40px;
    line-height: 20px;
    border:solid 1px black;
    position: relative;         // ...这里添加relative
    /*多行文本省略*/
    overflow : hidden;
    text-overflow: ellipsis;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;

    display: -moz-box;
    -moz-line-clamp: 2!important;
    -moz-box-orient: vertical;
}
// 后面自动补上点
div:after {
    background: linear-gradient(to right, rgba(255, 255, 255, 0), #FFFFFF 50%) repeat scroll 0 0 rgba(0, 0, 0, 0);
    bottom: 0;
    content: "...";
    padding: 0 5px 1px 30px;
    position: absolute;
    right: 0;
}

 

文本超出用...代替(兼容)