字符串最多2行, 溢出文字省略号代替

2018-01-23  本文已影响10人  Oo晨晨oO

html中:

<div class="two-line-string">
    <span>这里写文字</span>
</div>

css中:

.two-line-string {
        width: 240px;
        height: 48px;
        padding-right: 20px;
        line-height: 24px;
        // ------核心代码------
        display: flex;
        flex-direction: row;
        overflow : hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        text-align: left;
        justify-content: center;
        // ------核心代码------
      }
上一篇 下一篇

猜你喜欢

热点阅读