css-文字溢出省略号显示

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 150px;
            height: 50px;
            border: 1px solid pink;
            /* 有空白区域也不能换行 */
            /* white-space: nowrap; */
            /* 超出部分隐藏 */
            /* overflow: hidden; */
            /* 超出部分文字用省略号显示 */
            /* text-overflow: ellipsis; */
            /* 多行文本超出显示省略号, 有兼容性的问题 */
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
    </style>
</head>

<body>
    <div>什么也不说了,此处省略一万字什么也不说了,此处省略一万字</div>
</body>

</html>
posted @ 2025-09-24 09:14  紫川先生  阅读(22)  评论(0)    收藏  举报