trying to figure this out for a while.
I have a paragraph inside a scrollable (both axis) div with a mask that fades top and bottom edge. However, I need to fade out also left and right edge. There's a mask offset on the right for a scrollbar, same one should be at the bottom.
Here's the code:
.visible {
height: 10rem;
width: 20rem;
overflow: auto;
padding: 1.125rem;
}
.masked-overflow {
--mask-image-content: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent 100%);
--mask-size-content: calc(100% - 1.0625rem) 100%;
--mask-image-scrollbar: linear-gradient(black, black);
--mask-size-scrollbar: 1.0625rem 100%;
-webkit-mask-image: var(--mask-image-content), var(--mask-image-scrollbar);
-webkit-mask-size: var(--mask-size-content), var(--mask-size-scrollbar);
-webkit-mask-position: 0 0, 100% 0;
-webkit-mask-repeat: no-repeat, no-repeat;
mask-image: var(--mask-image-content), var(--mask-image-scrollbar);
mask-size: var(--mask-size-content), var(--mask-size-scrollbar);
mask-position: 0 0, 100% 0;
mask-repeat: no-repeat, no-repeat;
}
p {
width: 30rem;
font-size: 1rem;
margin-bottom: 1rem;
}
<div class="visible masked-overflow">
<p class="product-description">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed qu</p>
</div>
I tried to add second mask, but it takes only one of them. Also tried to ask AI, didn' help me with this one. This post is similar but has no offset for the scrollbars.
Using multiple masks will be tricky so here is an idea where I will add an extra wrapper to keep the mask easy
.visible {
height: 10rem;
width: 20rem;
}
.visible > div {
height: 100%;
width: 100%;
padding: 1.125rem;
box-sizing: border-box;
overflow: auto;
}
.masked-overflow,
.masked-overflow > div{
--s: 14px; /* scrollbar size */
-webkit-mask:
conic-gradient(at bottom var(--s) right var(--s) ,#000 75%,#0000 0),
linear-gradient(to var(--d,top) ,#0000 ,#000 20% 80%,#0000) no-repeat
0 0/calc(100% - var(--s)) calc(100% - var(--s));
}
.masked-overflow > div {
--d: right;
}
p {
width: 30rem;
font-size: 1rem;
margin-bottom: 1rem;
}
<div class="visible masked-overflow">
<div>
<p class="product-description">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed qu</p>
<div>
</div>