I'm currently working on creating an image element with overlay text. Check out my jsx
code below:
<div className={styles.img}>
<img src={src} alt="" />
<p>{`(${size})`}</p>
</div>
And here is the accompanying sass
styling:
.img {
min-width: 180px;
text-align: center;
cursor: pointer;
img {
height: 90px;
box-shadow: orangered 0 0 5px;
}
p {
color: white;
font-weight: bold;
margin: auto;
font-size: .8rem;
margin-top: - 1.6rem;
// max-width: 120px;
// z-index: 100;
background-color: #0070f3;
}
}
After implementing this, I encountered an issue where the background of the p
tag was only visible outside of the img
and not over it. See the result in the following image:
https://i.stack.imgur.com/OyjuA.png
You can also view the live issue here.
How can I adjust the styling to display the background for the overlay text on the image for better readability?