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

Categories

0 votes
4.0k 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...