i have a div container which is about 600px of width. I'm displaying an image inside this container. I have given the image a width:100%
and height:'auto'
. There are no issues in this but when i have to display a small image (Ex:width around 50px),because the width is set to 100% it appears blurry. How can i prevent this from happening? My thought was to however getting the width of the image and if it's lower than let's say 80px, the image width is set to a lower value. Is it the correct approach to do this? Or is there any better way?
My code
<div className="home_post_sections">
<img src={image} className="homepost_image"/>
</div>
css
.home_post_sections {
width: 610px;
display: block;
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
margin-bottom: 10px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: white;
}
.homepost_image {
width: 100%;
}