zoukankan      html  css  js  c++  java
  • 用省略号替代文字超出部分

    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>
            p{
                width: 200px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow:ellipsis;
            }
        </style>
    </head>
    
    <body>
        <p>很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长</p>
    </body>
    </html>

     多行文本超出

    <!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: 200px;
                height: 40px;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
                overflow: hidden;
            }
        </style>
    </head>
    
    <body>
        <div>
            很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长 很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长 很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长
        </div>
    </body>
    </html>

    参考地址:地址

  • 相关阅读:
    二叉树的序列化与反序列化
    寻找重复的子树
    [ABC216H] Random Robots
    Codeforces Round #741 (Div. 2)
    [Gym 102798K] Tree Tweaking
    CF798E Mike and code of a permutation
    CF1149E Election Promises
    [BZOJ 4311] 向量
    CF1268D Invertation in Tournament
    [做题笔记] 浅谈势能线段树在特殊区间问题上的应用
  • 原文地址:https://www.cnblogs.com/wuqiuxue/p/9065083.html
Copyright © 2011-2022 走看看