How to set window shadow using javascript?

I know you can do the following:

element.style.box-shadow ="something"; 

How would I cover the extensions -moz and -webkit?

If I did element.style.-webkit-box-shadow="something" and element.style.-moz-box-shadow="something" would I be covered?

+4
source share
3 answers

This parameter is called webkitBoxShadow , mozBoxShadow , etc. - to convert the name of the CSS parameter to the .style. property .style. remove the leading trait and then convert it from lowercase-with-dashes to lowerCamelCase.

+8
source

It would be better to set a class declaring these shadow properties for different browsers and adding this class to the className target element.

sort of:

 .shadowed{ /*all shadow declarations for various browsers*/ -o- -webkit- -moz- -ms- box-shadow } element.className += ' shadowed'; 
+4
source
 element.style['-webkit-box-shadow'] = "something"; 

Or in Mozilla:

 element.style['-moz-box-shadow'] = "something"; 
0
source

Source: https://habr.com/ru/post/1413396/


All Articles