css 列表样式,<a> 连接文字超长省略

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            /* 内减模式 */
            box-sizing: border-box;
        }
        .news{
            width: 500px;
            /* height: 400px; */
            border: 1px solid #ccc;
            margin: 50px auto;
            padding: 42px 30px 50px; /*内容自动离边框的距离*/
        }
        .news h3{
            color: #666;
            border-bottom: solid 1px #ccc;
            padding-bottom: 5px;
            font-size: 29px;
        }

        .news li{
            list-style-type:none;   /*去掉默认的样式*/
            border-bottom: 1px dashed #666;
            height: 50px;
            /* padding-left: 50px; */

           
        }
        .news li a{
            text-decoration: none;
            color:  #666;
            line-height: 50px;
            padding-left: 20px;

            white-space: nowrap;    /*一行 不换行*/
            overflow: hidden;   /*超出隐藏*/
            text-overflow: ellipsis; /*要有超出显示的样式*/
            display: block;
            width: 438px;
        }
    </style>
</head>
<body>
    <div class="news">
        <h3>国内新闻:朝闻天下-新闻天天看</h3>
        <ul>
            <li><a href="#">普京“罕见讲话” 释放三个重要信息热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热甘宇全身多处骨折伴有严重感染热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热</a></li>
            <li><a href="#">甘宇全身多处骨折伴有严重感染热</a></li>
        </ul>
    </div>
</body>
</html>

 

 

效果:如下

posted on 2022-09-22 10:49  totau  阅读(73)  评论(0编辑  收藏  举报

导航