css3 - 這種情景怎么解釋?display:flex 遭遇 white-space: nowrap;
問題描述
html如下,使用了flex-box布局,左邊圖片的img-box定寬,右邊的css定義了flex-item,然后對shop-name進行了單行不換行截斷,這時候就發現左邊的圖片被擠扁了,小于定的寬度。發生這個情況在chrome上,ios和安卓的微信下正常.
chrome效果見圖:
<a href='http://www.aoyou183.cn/wenda/5874.html#' class='coupons-item flex'> <p class='img-box'><img src='http://www.aoyou183.cn/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. mysql優化 - mysql count(id)查詢速度如何優化?2. mysql主從 - 請教下mysql 主動-被動模式的雙主配置 和 主從配置在應用上有什么區別?3. angular.js - 不適用其他構建工具,怎么搭建angular1項目4. 主從備份 - 跪求mysql 高可用主從方案5. css3 - [CSS] 動畫效果 3D翻轉bug6. node.js - node_moduls太多了7. angular.js - angularjs 用ng-reapt渲染的dom 怎么獲取上面的屬性8. python如何不改動文件的情況下修改文件的 修改日期9. python - django 里自定義的 login 方法,如何使用 login_required()10. android-studio - Android 動態壁紙LayoutParams問題
![css3 - [CSS] 動畫效果 3D翻轉bug](http://www.aoyou183.cn/attached/image/news/202304/110831f073.png)