I made the brightness for an image: filter: brightness(40%)
but I made a overlay with text that’s in the center of the image and I want the text to have a normal brightness (unlike the image).
Can anyone help me make the Instagram icon have a normal brightness?
.instacont {
filter: brightness(40%);
width: 250px;
display: flex;
}
.insta-container {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
.overlay {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
filter: brightness(100%);
color: white;
font-size: 23px;
text-align: center;
}
#seimg {
width: 287px;
display: flex;
margin-left: -5px;
}
.insta {
display: flex;
width: 287px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" rel="stylesheet"/>
<div class="insta-container">
<div class="instacont">
<img class="insta" src="https://i.pinimg.com/736x/2c/fc/71/2cfc71b0af14a2d2a20fe8048f3bd8ef.jpg">
<div class="overlay"><i class="fab fa-instagram fa-2x" style="color: #ffffff;" id="instaicon"></i></div>
</div>
</div>
2
Answers
With the following part of your css, you put a filter on all the elements with class
instacont
, and implicitly everything inside of it as well:You can put the filter on just the element you want filtered directly.
Move the
filter: brightness(40%);
to.insta
instead:The
filter: brightness(100%);
in.overlay
is not needed and can be removed.Switch the
filter
from theinstacont
element to just the image element.Small further note: at the moment your positioning for the icon is off. If you use
display: flex
on the overlay you can then center it properly withjustify-content
andalign-items
. You can also remove one layer of nesting by setting the container to use relative positioning.(I’ve renamed the classes in this updated example to make it a little more explanatory.)