[英]CSS issue with height and width of image
我在div的jsx / html頁面上有圖像:
<div className="card-row-image" style={getBackgroundImage(thumbnail)} />
問題是cus中CSS類的height
和width
為68px
但是當我打開應用程序時,頁面寬度68px
CSS部分代碼:
.card-row-image {
height: 68px;
width: 68px;
border-radius: 4px;
margin-right: 10px;
background-size: cover;
background-position: center center;
}
為什么用的圖像不是68px?
與鏈接到該類的CSS規則相比, getBackgroundImage(thumbnail)
提供的內聯樣式具有更高的優先級。 您有兩種選擇:
更改getBackgroundImage
以允許指定其他大小(不是'thumb')
應用內聯樣式,但從其中刪除寬度和高度:
const { width, height, ...styleWithoutSize } = getBackgroundImage(thumbnail)
<div className="card-row-image" style={styleWithoutSize} />
!important
更改優先級順序 .card-row-image {
height: 68px !important;
width: 68px !important;
border-radius: 4px;
margin-right: 10px;
background-size: cover;
background-position: center center;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.