css3 - 这种情景怎么解释?display:flex 遭遇 white-space: nowrap;
问题描述
html如下,使用了flex-box布局,左边图片的img-box定宽,右边的css定义了flex-item,然后对shop-name进行了单行不换行截断,这时候就发现左边的图片被挤扁了,小于定的宽度。发生这个情况在chrome上,ios和安卓的微信下正常.
chrome效果见图:
<a href='https://www.haobala.com/wenda/5874.html#' class='coupons-item flex'> <p class='img-box'><img src='https://www.haobala.com/wenda/1.jpg' /></p> <p class='flex-item'><h3 class='shop-name'>有家餐厅(京华城店)</h3><p class='text'>满100减20</p> </p></a>
(scss)
.coupons-item{ padding:1rem; color:#000; text-decoration: none; border-bottom:1px solid $gray-border-color; .img-box{ width:6rem; height:6rem; margin-right:1rem; @include radius(50%); overflow: hidden; img{ display: block; width:100%; height:100%; @include radius(50%); } } .shop-name{ line-height:2; height:3.6rem; font-weight:normal; font-size:1.8rem; overflow: hidden; -ms-text-overflow: ellipsis; text-overflow: ellipsis; white-space: nowrap; } .text{ font-size:1.4rem; }}
问题解答
回答1:之前遇到过,解决办法:首先.flex-item设置下最小宽度
min-width:0
然后.shopname设置下宽度
width:100%回答2:
shop-name定义宽度浮动试下
回答3:给.shop-name设一个最大宽度试试吧
相关文章:
1. javascript - 读js权威指南“作为值得函数”产生了疑惑,求释疑2. 请问带渐变背景的进度条如何实现?求给点思路3. file - Python如何读文件内容修改后写回原文件4. python中merge后文件莫名变得非常大5. javascript - 为什么 process.stdin 会有 write 方法◔ ‸◔?6. boostrap怎么在移动端不显示sidebar?7. android - 使用listview加载不同item,数据填充错误。8. python3.x - python中的虚拟环境怎样设置一直处于激活状态9. java - 怎么处理前台要展示,但是数据库表没有该字段的实体类冗余属性呢?10. mysql - 数据库建字段,默认值空和empty string有什么区别 110