I have an api that fetches the images of dogs and I want to apply heart icon (like favourite feature) over it . When clicked , that image should also get display on the favourites section. I am not able to find to how to apply heart icon over the images.
<div className="container3">
{
imageUrls && imageUrls.map(record => {
return (
<>
< div className="col-sm" >
<img src={record} alt='i'></img>
<FontAwesomeIcon icon={faHeart} className='heart-icon' style={{color: "#ff0000",}} />
</div>
</>
)
})
}
</div>
Can anybody help me with the css
I am getting heart icon above the images and also not in same alignment. I want the heart icon to be at the bottom right of the image.
2
Answers
I recomend using absolute positioning to achive this. Put your icon element as a child of the image element, then give the child this css:
You can achieve this by setting a
position: absolute
on the icon. Make sure theimg
is wrapped by adiv
, set the width and height you want on thediv
and then set theimg
to width and height of 100%. Make sure the icon is within the samediv
and set the position on the icon to absolute e.gposition: absolute
.