Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

javascript - SVG Filters Turn Off My CSS Filters. Why?

Stepping through my page, this line of code turns off my SVG Filter:

if (document.getElementById("cPreview") != null) document.getElementById("cPreview").style.filter =  "brightness(" + parseInt(percentB) + "%)" + " contrast(" + parseInt(percentC) + "%)" +  " saturate(" + parseInt(percentS) + "%)";  

If I add SVG code to that, my CSS Filters are turned off:

if (document.getElementById("cPreview") != null) document.getElementById("cPreview").style.filter = svgCOLOR + "brightness(" + parseInt(percentB) + "%)" + " contrast(" + parseInt(percentC) + "%)" +  " saturate(" + parseInt(percentS) + "%)";  

How do I code that so the SVG Filter and the CSS Filters play nicely together?

Thank you


Someone asked for an example. Here is the original image:

enter image description here

Here is the image with the CSS Filters applied:

enter image description here

Here is the image with the SVG Filter applied:

enter image description here

The image with all filters applied. I had to make this in a photo editor because that one line of code isn't working. It all comes down to that one line of code posted above. I can make CSS work, or make SVG work, but I cannot make both work together. Thank you

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...