I have a challenge where I need to hide an image or i
tag within a wrapper div if there is a background image present. The idea is that the icon inside the wrapper div should only be visible when there is no background image, and as soon as a background image is set, it should overlap and hide the icon.
However, my issue is that currently both the icon and the background color of the div are being displayed simultaneously.
HTML
<div class="img-fluid rounded-circle avatar">
<i class="material-icons icon">account_circle</i>
</div>
CSS
.avatar {
width: 40px;
height: 40px;
border: 1px solid cadetblue;
display: flex;
align-items: center;
justify-content: center;
background-color: cadetblue;
background-position: 50% 50%;
background-size: cover;
position: relative;
}
.icon {
}