I would like to have transparency effect on element working on any background color. How to do that with pseudo-elements like :before and :after? I need this effect for scroll fade out effect. Code below does not work
Effect I would like to achieve (working on any background):
<style>
.faded {
width: 100px;
/* background: red; should work with any background */
}
.faded::before {
content: "''";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 50px;
z-index: 1;
-webkit-mask-image: linear-gradient(
to bottom,
black 0%,
transparent 100%
);
}
</style>
<div class="faded">Blablabla babalbalbalba balblablablal</div>