Problem Statement:
Hi, I want to fade out the div and it's contents from the left and right edge using pure CSS. Currently I'm able to achieve this based on an answer to a question on stack overflow.
Code:
.container {
height: 234px;
width: 234px;
overflow: scroll;
mask-image: linear-gradient(transparent,
black 20%,
black 80%,
transparent 100%);
-webkit-mask-image: linear-gradient(transparent,
black 20%,
black 80%,
transparent 100%);
}
.container::-webkit-scrollbar {
display: none;
}
<div class="container">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit
dolorem libero, dolor, fuga illo nobis rem ipsam ipsa
perferendis dolore autem fugiat! Dicta eius repellendus totam
qui maiores odio a! Lorem ipsum dolor sit amet consectetur
adipisicing elit. Impedit dolorem libero, dolor, fuga illo nobis
rem ipsam ipsa perferendis dolore autem fugiat! Dicta eius
repellendus totam qui maiores odio a! Lorem ipsum dolor sit amet
consectetur adipisicing elit. Impedit dolorem libero, dolor,
fuga illo nobis rem ipsam ipsa perferendis dolore autem fugiat!
Dicta eius repellendus totam qui maiores odio a! Lorem ipsum
dolor sit amet consectetur adipisicing elit. Impedit dolorem
libero, dolor, fuga illo nobis rem ipsam ipsa perferendis dolore
autem fugiat! Dicta eius repellendus totam qui maiores odio a!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Impedit
dolorem libero, dolor, fuga illo nobis rem ipsam ipsa
perferendis dolore autem fugiat! Dicta eius repellendus totam
qui maiores odio a! Lorem ipsum dolor sit amet consectetur
adipisicing elit. Impedit dolorem libero, dolor, fuga illo nobis
rem ipsam ipsa perferendis dolore autem fugiat! Dicta eius
repellendus totam qui maiores odio a!
</p>
</div>
How can I do make the linear gradient make left and right edges fade instead of top and bottom?
Also: This syntax is pretty neat but I fail to understand that how the args passed to linear-gradient are able to specify to fade the container only from top and bottom, and leave the rest as it is. In short, we have not specified any directions something like to-top
and to-bottom
so how's this actually working?
NOTE: I know this question is a duplicate of this. But the answer specified on the question does not solve my use case, as it's not fading out the inner content of the div.
Thanks! :)