css3 - 這種情景怎么解釋?display:flex 遭遇 white-space: nowrap;
問題描述
html如下,使用了flex-box布局,左邊圖片的img-box定寬,右邊的css定義了flex-item,然后對shop-name進行了單行不換行截斷,這時候就發現左邊的圖片被擠扁了,小于定的寬度。發生這個情況在chrome上,ios和安卓的微信下正常.
chrome效果見圖:
<a href='http://m.4tl426be.cn/wenda/5874.html#' class='coupons-item flex'> <p class='img-box'><img src='http://m.4tl426be.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. python - Win7調用flup報錯’module’ object has no attribute ’fromfd’2. 網頁爬蟲 - Python 爬蟲中如何處理驗證碼?3. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處4. Python如何播放還存在StringIO中的MP3?5. javascript - 請教如何獲取百度貼吧新增的兩個加密參數6. mysql 一個sql 返回多個總數7. python - 我在使用pip install -r requirements.txt下載時,為什么部分能下載,部分不能下載8. mysql - 如何減少使用或者不用LEFT JOIN查詢?9. Python爬蟲如何爬取span和span中間的內容并分別存入字典里?10. python - 編碼問題求助
