惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
IT之家
IT之家
博客园 - 聂微东
The Cloudflare Blog
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
H
Help Net Security
博客园 - 叶小钗
V
V2EX
WordPress大学
WordPress大学
J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
C
Check Point Blog
B
Blog
D
DataBreaches.Net
美团技术团队
罗磊的独立博客

博客园 - smile轉角

【js】ES5,ES6继承是如何实现的 【js】setTimeout、Promise、Async/Await 的区别 【面试题】思维逻辑方面 【js】js内置对象Error(错误机制) 【TS】学习笔记 【js】CommonJS、AMD、CMD三种规范 【其他】查看Animate.css官网动画没有效果 【vue3】父子组件通信之 vue3 defineProps,defineEmits ,defineExpose 【js】JS严格模式有什么特点 【vue】 Failed to load resource: the server responded with a status of 404 (Not Found) 【第三方】富文本调研 【js】元素是否在可视区范围内 【js】json的相关操作 【vue3】资料 【css】展示背景图片的底部部分 【html】 svg 【html5】html5中input 标签 type值为range时,修改其默认css 【js】forEach,for...in,for...of 区别 【js】map,reduce,filter的区别
【css】使用弹性盒子布局时,省略号问题
smile轉角 · 2023-01-12 · via 博客园 - smile轉角

栗子:

<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>弹性盒子省略号问题</title>

    <style>
        *{
            margin: 0;
            padding: 0;
        }
  
.ui-flex { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; } .ui-flex-1 { -webkit-box-flex: 1; -webkit-flex: 1; -ms-flex: 1; flex: 1; } .ui-flex-basis{ flex: 1 0 0; } .ut-s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ut-s-line{ display: -webkit-box; /**对象作为伸缩盒子模型展示**/ -webkit-box-orient: vertical; /**设置或检索伸缩盒子对象的子元素的排列方式**/ -webkit-line-clamp: 1; /**显示的行数**/ overflow: hidden; /**隐藏超出的内容**/ text-overflow: ellipsis; white-space: normal; word-break: break-all; /*允许在单词内换行*/ } .ut-s-line2{ display: -webkit-box; /**对象作为伸缩盒子模型展示**/ -webkit-box-orient: vertical; /**设置或检索伸缩盒子对象的子元素的排列方式**/ -webkit-line-clamp: 2; /**显示的行数**/ overflow: hidden; /**隐藏超出的内容**/ text-overflow: ellipsis; white-space: normal; word-break: break-all; /*允许在单词内换行*/ } .main-container{ width:500px; margin: 0 auto; } .box{ border:1px solid red; padding:10px; } h6{ margin:20px; text-align: center; } .box-left{ width: 200px; height: 200px; border:1px solid #ccc; margin-right: 20px; } .box-right-bottom{ padding:10px 0; } .box-right-top{ } .box-right-title{ width:calc(100% - 222px ); } </style> </head> <body> <div class="main-container"> <h6>容器1(ui-flex容器内直接包裹内容,然后使用省略号的css代码即实现 )</h6> <div class="ui-flex box"> <div class="box-left"></div> <div class="box-right ui-flex-1 ut-s"> 我是标题我是表我是标题我是表我是标题我是表我是标题我是表 </div> </div> <h6>容器2</h6> <div class="ui-flex box"> <div class="box-left"></div> <div class="box-right ui-flex-1"> <div class="box-right-top ut-s">我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题</div> <div class="box-right-bottom"> 2023年1月12日</div> </div> </div> <h6>容器3(对象作为伸缩盒子模型展示 display:box)</h6> <div class="ui-flex box"> <div class="box-left"></div> <div class="box-right ui-flex-1"> <div class="box-right-top ut-s-line">我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题</div> <div class="box-right-bottom"> 2023年1月12日</div> </div> </div> <h6>容器4(指定弹性元素的宽度)</h6> <div class="ui-flex box"> <div class="box-left"></div> <div class="box-right ui-flex-1" style="width:calc(100% - 222px)"> <div class="box-right-top ut-s">我是标题我是标题我是标题我是标题我是标题我是标题我是标题我是标题</div> <div class="box-right-bottom"> 2023年1月12日</div> </div> </div> </div> </body> </html>

效果:

 

 相关资料: