css3 - 這種情景怎么解釋?display:flex 遭遇 white-space: nowrap;
問題描述
html如下,使用了flex-box布局,左邊圖片的img-box定寬,右邊的css定義了flex-item,然后對shop-name進行了單行不換行截斷,這時候就發(fā)現(xiàn)左邊的圖片被擠扁了,小于定的寬度。發(fā)生這個情況在chrome上,ios和安卓的微信下正常.
chrome效果見圖:
<a href='http://m.baoyu77737.com/wenda/5874.html#' class='coupons-item flex'> <p class='img-box'><img src='http://m.baoyu77737.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設(shè)置下最小寬度
min-width:0
然后.shopname設(shè)置下寬度
width:100%回答2:
shop-name定義寬度浮動試下
回答3:給.shop-name設(shè)一個最大寬度試試吧
相關(guān)文章:
1. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題2. javascript - QWebEngineView 如何爬 angular 的動態(tài)數(shù)據(jù)?3. javascript - 使用angular 的ui-sref 中出現(xiàn)了中文參數(shù),點擊跳轉(zhuǎn)后瀏覽器的地址欄里出現(xiàn)轉(zhuǎn)義后的%AE....%a%44. java - ConcurrentHashMap中的get()方法為什么可以不加鎖?5. java - 郵箱如何發(fā)送html內(nèi)容6. html5 - 這個代碼顯示功能如何實現(xiàn)?7. javascript - 用JS 七牛上傳圖片出現(xiàn)文件已存在的錯誤(file exists)8. 工作近5年,3年Java Web ,近2年前端,未來何去何從?9. css3 - 圖片等比例縮放10. java - 字節(jié)流轉(zhuǎn)成字符串之后,在通過字符串轉(zhuǎn)成字節(jié)流后的文件為什么會不一樣?
