成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

這種情景怎么解釋?display:flex 遭遇 white-space: nowrap;

瀏覽:123日期:2024-05-28 11:34:27

問題描述

html如下,使用了flex-box布局,左邊圖片的img-box定寬,右邊的css定義了flex-item,然后對(duì)shop-name進(jìn)行了單行不換行截?cái)啵@時(shí)候就發(fā)現(xiàn)左邊的圖片被擠扁了,小于定的寬度。發(fā)生這個(gè)情況在chrome上,ios和安卓的微信下正常.

chrome效果見圖:

這種情景怎么解釋?display:flex 遭遇 white-space: nowrap;

<a href="#" class="coupons-item flex"> <div class="img-box"><img src="1.jpg" /></div> <div class="flex-item"><h3 class="shop-name">有家餐廳(京華城店)</h3><div class="text">滿100減20</div> </div></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%

相關(guān)文章: