Problem with background-blend-mode in CSS
See original GitHub issueFor some reason -blend-mode
is out of hljs-attribute
scope:
background-image: url(images/sample.png);
background-color: red;
background-blend-mode: multiply;
<span class="hljs-attribute">background</span>-blend-mode<span class="hljs-value">: multiply;</span>
Issue Analytics
- State:
- Created 9 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
CSS Blend Mode not working - Stack Overflow
I would like to play with the CSS blend mode property but it seems like nothing is happening when I apply the rules....
Read more >background-blend-mode - CSS: Cascading Style Sheets | MDN
If the blending modes' and background images' list lengths are not equal, it will be repeated and/or truncated until lengths match.
Read more >background-blend-mode | CSS-Tricks
The background-blend-mode property defines how an element's background-image should blend with its background-color:
Read more >Mix-blend-mode not working - Custom code - Forum | Webflow
In order for the mix-blend-mode style to work, you need to have a background color set for your main container element—even if you're...
Read more >CSS background-blend-mode | Can I use... Support ... - CanIUse
CSS background-blend-mode. - CR. Allows blending between CSS background images, gradients, and colors. Usage % of ... Known issues (1) Resources (5)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, we could just add
background-blend-mode
to fix this particular case. I’ll gladly merge the pull request for that, as it won’t break anything.This doesn’t really solve the problem though: new properties appear constantly and nobody wants to maintain it. And if you add SVG and potentially every XML application that could be styled this simply looks unfeasible.
What we could do is similar to what @tonyganch is describing: we could define “css-properties” as a separate language and use it inside CSS as well as on its own. But it’ll have to wait some time as it must be done carefully and we have a release planned for tomorrow 😃.
BTW, the approach “try everything and stick with what worked” isn’t really that slow. In fact, it’s how we do language detection: we literally try to highlight code with every language we known and stick with the one that successfully highlighted most stuff. The secret of being fast is to bail out early on obvious erros, which is why CSS defined strictly.
If you’re wanting a fix just for yourself I’d consider what I just suggested… and make sure you explicitly label your blocks CSS.
I just tried VS Code just now and even it can’t properly colorize CSS “out of context”. If you had a blog or somewhere where you constantly were posting such things I’d almost suggest you whip up your own
cssprops
grammar just for this usage.Closing because it’s really impossible to resolve this while keeping auto-detect in mind.
Also just wrapping the whole thing in {} without a selector even seems to work if you were willing to change your snippets: