超长溢出头部省略打点,坑这么大,技巧这么多?
2023-04-27 14:02 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>
方案二:通过伪元素破坏其纯数字的性质、

<!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>
方案四:通过 <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>
转载 超长溢出头部省略打点,坑这么大,技巧这么多? - 掘金 (juejin.cn)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了