Masking

I am trying to mask an svg with a solid color. I know I can only mask with a gradient or an image. Is there another option to mask with a solid color?
29 Replies
Mannix
Mannix•17mo ago
you can always set gradient as solid color 😄
capt_uhu
capt_uhu•17mo ago
i'd need some more specific info about what you're trying to do to help here. Can you throw what you have in a codepen?
Spiritual Tech
Spiritual Tech•17mo ago
That doesn't work
MarkBoots
MarkBoots•17mo ago
-webkit-mask-image: linear-gradient(black, transparent)
mask-image: linear-gradient(black, transparent)
-webkit-mask-image: linear-gradient(black, transparent)
mask-image: linear-gradient(black, transparent)
should work as mask
Spiritual Tech
Spiritual Tech•17mo ago
Oh, I see
MarkBoots
MarkBoots•17mo ago
so, just repeat the same 2 times and it is solid
Spiritual Tech
Spiritual Tech•17mo ago
What do you mean?
MarkBoots
MarkBoots•17mo ago
black, transparent is a gradient
Mannix
Mannix•17mo ago
black, black instead of black, transparent
Spiritual Tech
Spiritual Tech•17mo ago
Oh
MarkBoots
MarkBoots•17mo ago
black is visable, transparent is masked
Spiritual Tech
Spiritual Tech•17mo ago
The color isn't showing up. I made it blue and it is still black.
MarkBoots
MarkBoots•17mo ago
youll have to show an example if it doesnt work as expected
Spiritual Tech
Spiritual Tech•17mo ago
How do I ad a code block to this chat?
MarkBoots
MarkBoots•17mo ago
codepen is the easiest, then we can see it live https://codepen.io
CodePen
An online code editor, learning environment, and community for front-end web development using HTML, CSS and JavaScript code snippets, projects, and web applications.
Mannix
Mannix•17mo ago
you want to set an background on the element and use the svg as the mask 😉
MarkBoots
MarkBoots•17mo ago
ohw, that's something totaly diff
Mannix
Mannix•17mo ago
MarkBoots
MarkBoots•17mo ago
mask a color with a svg, not mask a svg with a color
Spiritual Tech
Spiritual Tech•17mo ago
That was my understanding and I tried that already. Maybe I did something wrong. How do I set up the css?
Mannix
Mannix•17mo ago
background: blue;
mask-image: url(https://df-cdn.s3.us-east-1.amazonaws.com/DFS_LiveChat/site-logo.svg);
-webkit-mask-image: url(https://df-cdn.s3.us-east-1.amazonaws.com/DFS_LiveChat/site-logo.svg);
background: blue;
mask-image: url(https://df-cdn.s3.us-east-1.amazonaws.com/DFS_LiveChat/site-logo.svg);
-webkit-mask-image: url(https://df-cdn.s3.us-east-1.amazonaws.com/DFS_LiveChat/site-logo.svg);
on .dfs-live-chat-wrap div.dfs-site-logo
MarkBoots
MarkBoots•17mo ago
other option is to bring the inline svg in the html, then you can just change the fill color
Spiritual Tech
Spiritual Tech•17mo ago
We use an inject file for the html. I can't do it that way.
Spiritual Tech
Spiritual Tech•17mo ago
This is what the html looks like for the feature only.
Spiritual Tech
Spiritual Tech•17mo ago
Now I have a double image and I don't know why. But that worked, thank you.
Mannix
Mannix•17mo ago
because of the 100px width the image is shorter so it repeats
Spiritual Tech
Spiritual Tech•17mo ago
Okay
MarkBoots
MarkBoots•17mo ago
you can inject this instead of the image https://codepen.io/MarkBoots/pen/rNrdmmz
Spiritual Tech
Spiritual Tech•17mo ago
Success! Thank you so much! You're an angel!