I have image on jsx/html page that is div:
<div className="card-row-image" style={getBackgroundImage(thumbnail)} />
Problem is cus in css class height
and width
are 68px
but when I open application, on page width is lower then 68px
Css part of code:
.card-row-image {
height: 68px;
width: 68px;
border-radius: 4px;
margin-right: 10px;
background-size: cover;
background-position: center center;
}
Why with of image is not 68px?
The inline style provided in getBackgroundImage(thumbnail)
has a higher priority than the CSS rules linked to the class. You have a couple of options:
Change getBackgroundImage
to allow specifying another size (not 'thumb')
Apply the inline style, but remove the width and height from it:
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.