代码改变世界

超长溢出头部省略打点,坑这么大,技巧这么多?

  Bryran  阅读(9)  评论(0编辑  收藏  举报

 

方案一:两次 direction 反转

复制代码
<!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>
        div {
            margin-top: 4px;
            background-color: #bdc3c7
        }

        .m-b-12 {
            margin-bottom: 12px;
        }

        .w180 {
            width: 180px;
        }

        .g-twice-reverse {
            overflow: hidden;
            text-overflow: ellipsis;
            direction: rtl;
            white-space: nowrap;
        }

        .g-twice-reverse>span {
            direction: ltr;
            unicode-bidi: bidi-override;
        }

    </style>
</head>

<body>
    初始内容:
    <div class="m-b-12">13993199751_18037893546_4477656</div>

    省略后内容:
    <div class='w180 g-twice-reverse'>
        <span>13993199751_18037893546_4477656</span>
    </div>


</body>

</html>
套两层direction
复制代码

 

方案二:通过伪元素破坏其纯数字的性质、

复制代码
<!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>
        div {
            margin-top: 4px;
            background-color: #bdc3c7
        }

        .m-b-12 {
            margin-bottom: 12px;
        }

        .w180 {
            width: 180px;
        }

        .g-add-letter {
            overflow: hidden;
            text-overflow: ellipsis;
            direction: rtl;
            white-space: nowrap;
        }

        .g-add-letter>span::before {
            content: "a";
            opacity: 0;
            font-size: 0;
        }
    </style>
</head>

<body>
    初始内容:
    <div class="m-b-12">13993199751_18037893546_4477656</div>

    省略后内容:
    <div class='w180 g-add-letter'>
        <span>13993199751_18037893546_4477656</span>
    </div>


</body>

</html>
添加伪类
复制代码

 

方案三:通过 \200e LRM 标记位

复制代码
<!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>
        div {
            margin-top: 4px;
            background-color: #bdc3c7
        }

        .m-b-12 {
            margin-bottom: 12px;
        }

        .w180 {
            width: 180px;
        }

        .g-add-letter {
            overflow: hidden;
            text-overflow: ellipsis;
            direction: rtl;
            white-space: nowrap;
        }

        .g-add-letter>span::before {
            content: "\200e";
            opacity: 0;
            font-size: 0;
        }
    </style>
</head>

<body>
    初始内容:
    <div class="m-b-12">13993199751_18037893546_4477656</div>

    省略后内容:
    <div class='w180 g-add-letter'>
        <span>13993199751_18037893546_4477656</span>
    </div>


</body>

</html>
View Code
复制代码

 

方案四:通过 <bdi> 标签

 

 

复制代码
<!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>
        div {
            margin-top: 4px;
            background-color: #bdc3c7
        }

        .m-b-12 {
            margin-bottom: 12px;
        }

        .w180 {
            width: 180px;
        }

        .g-bid {
            overflow: hidden;
            text-overflow: ellipsis;
            direction: rtl;
            white-space: nowrap;
        }

    
    </style>
</head>

<body>
    初始内容:
    <div class="m-b-12">13993199751_18037893546_4477656</div>

    省略后内容:
    <div class='w180 g-bid'>
        <bdi dir="ltr">13993199751_18037893546_4477656</bdi>
    </div>


</body>

</html>
通过bdi
复制代码

 

 

 

 

 

 

 

转载 超长溢出头部省略打点,坑这么大,技巧这么多? - 掘金 (juejin.cn)

 

相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
点击右上角即可分享
微信分享提示