I'm creating a website on my own using html+css and jquery. Recently started using SASS that comes with Autoprefixe just so I can get some formatting done more easily and be able to use sass libraries down the line.
I'm trying to apply a gradient alpha mask to some menu items that I've gotten to loop in a "marquee style".
I started by creating the image for the mask in a background-image tag. The idea is that there are two boxes above and under the menu, because of how alpha fade works, black part will be clearest when the mask is applied and the transparent part of the boxes will be where the text disappears. After some tweaking I got it looking like this:
.marquee:before {
transform: translateX(-50%);
top: 0;
background-image: linear-gradient(to top,rgb(0, 0, 0) 0%, transparent 100%);
}
.marquee:after {
bottom:0;
background-image: linear-gradient(to bottom,rgba(0, 0, 0, 100) 0%, rgba(0, 0, 0, 0) 100%);
transform: translateX(-50%);
}
But when I switch the background-image property to mask-image, it doesn't really mask the marquee-content(menu items). In fact it seems like the black boxes just disappear, with no masking happening whatsoever.
.marquee {
width: var(--marquee-width);
height: 30vh;
overflow: hidden;
position: relative;
}
.marquee:before, .marquee:after {
position: absolute;
width: var(--marquee-width);
height: 1.5rem;
content: "";
z-index: 1;
}
.marquee:before {
transform: translateX(-50%);
top: 0;
mask-image: linear-gradient(to top,rgb(0, 0, 0) 0%, transparent 100%);
}
.marquee:after {
bottom:0;
mask-image: linear-gradient(to bottom,rgba(0, 0, 0, 100) 0%, rgba(0, 0, 0, 0) 100%);
transform: translateX(-50%);
}
.marquee-content {
margin-bottom:-1vh;
list-style: none;
height: 100%;
display: inline-flexbox;
animation: scrolling var(--marquee-animation-duration) linear infinite ;
animation-delay: 4s;
}
At this point I'm not exactly sure what's going wrong, the same happens on firefox, even though I use autoprefixer, which means that I'm not doing something right on the logic side. From what I read alpha masks should apply to children of elements as well, so my masks should be masking out marquee-content.
Here's my HTML structure for reference
<!---Menu Container-->
<div class="menucontainer" id="fixedMenu">
<nav class="nav">
<li class=active></li>
<li class="menutitle scrollTop" id="myTitle">CIVR1</a></li>
<ul class="marquee">
<ul class="marquee-content">
<li><a class="menuitems nav-section1" href="#TheInitiator">the initiator</a></li>
<li><a class="menuitems nav-section2" id="m2" href="#TheJourney">the journey</a></li>
<li><a class="menuitems nav-section3" id="m3" href="#PatronOfTheSea">patron of the sea</a></li>
<li><a class="menuitems nav-section4" id="m4" href="#ExtremeBodies">extreme bodies</a></li>
<li><a class="menuitems nav-section5" id="m5" href="#DownloadVR">download vr</a></li>
<li><a class="menuitems nav-section6" id="m6" href="#PerformanceLibrary">performance library</a></li>
<li><a class="menuitems nav-section7" id="m7" href="#Partners">partners</a></li>
<li><a class="menuitems nav-section8" id="m8" href="#Contact">contact</a></li>
</ul>
</ul>
</nav>
</div>
So yeah, I've been banging my head on the wall for this, Any help or suggestions are very much welcome! Is there another way to achieve this effect? A better one? Am I just bad?
*I also did the masks with rgb and rgba intentionally to see if it was an issue. It wasn't. :<