CSS.supports() , which I will write about below. With this directive, you can check the browser for support of the specified CSS properties. @supports (property: value) { /* */ } display: flex property, it will launch the properties from the directive. @supports (display: flex) { /* */ } display: flex , then it will run the properties from the directive @supports not (display: flex) { /* */ } display: flex or display: -webkit-flex , then it will run the properties from the directive @supports (display: flex) or (display: -webkit-flex) { /* */ } display: flex and display: -webkit-flex , then it will run the properties from the directive @supports (display: flex) and (display: -webkit-flex) { /* */ } display: flex or display: -webkit-flex , and flex-wrap: wrap , then it will run the properties from the directive @supports ((display: flex) or (display: -webkit-flex)) and (flex-wrap: wrap) { /* */ } Note: the@supportsdirective@supportsfairly new and IE does not support it.
CSS.supports() , which I mentioned above.CSS.supports() function returns true if the property is supported, and false if not.display: flex , the script returns true . CSS.supports("display", "flex"); /* true / false */ display: flex or display: -webkit-flex , and flex-wrap: wrap , then the script returns true . CSS.supports("((display: flex) or (display: -webkit-flex)) and (flex-wrap: wrap)"); /* true / false */ Note: as well as the @supports directive, this function is new and IE does not support it. var SupportsCSS = function (property, value) { try { // var element = document.createElement('span'); // , if (element.style[property] !== undefined) element.style[property] = value; // , else return false; // , false // , return element.style[property] === value; } catch (e) { // IE, , , return false; } }; try...catch if we write properties via cssText : var SupportsCSS = function (property, value) { // var element = document.createElement('span'); // , if (element.style[property] !== undefined) element.style.cssText = property + ':' + value; // style else return false; // , false // , return element.style[property] === value; }; SupportsCSS('display', 'flex'); /* true / false */ SupportsCSS('display', '-webkit-flex'); /* true / false */ SupportsCSS('display', '-ms-flexbox'); /* true / false */ Note: if you check the property support in the old browser, through a modern emulator, then this method will showtrueon values that are not supported.
This is due to the fact that even though you are emulating the old version, the browser through which you do this knows the value of the CSS properties and can apply.
Source: https://habr.com/ru/post/336466/
All Articles