How to detect CSS features

Source: Internet
Author: User

How to detect CSS features

If we want to detect whether a CSS property supports

var dom = document.createelement (' P '), if (' Textshadow ' in Dom.style) {    alert (' Support Textshadow attribute ')}else {    alert (' Textshadow attribute ' not supported ')}

If we want to detect if the CSS3 property supports a value

var dom = document.createelement (' P ');d om.style.backgroundImage = ' linear-gradient (red, tan) '; Dom.style.backgroundImage) {    alert (' supports this attribute value ');} else {    alert (' Browser does not support this property value ')}

How to dynamically assign a CSS3 effect and support all major browsers

function Islider () {};/** * @returns {String} * @private */islider.transition_end_event = Null;islider.browser_prefix = Nu    ll; (function () {var e = document.createelement (' fakeelement '); [[' Webkittransition ', ' webkittransitionend ', ' WebKit '], [' transition ', ' transitionend ', null], [' Moz Transition ', ' transitionend ', ' Moz '], [' otransition ', ' otransitionend ', ' O ']].some (function (t) {if (E.            Style[t[0]]!== undefined) {islider.transition_end_event = t[1];            Islider.browser_prefix = t[2];        return true; }    });}) ();/** * @param {string} prop * @param {string} value * @returns {string} * @public */islider.styleprop = function (prop, ISDP) {if (Islider.browser_prefix) {if (!!        ISDP) {return islider.browser_prefix + IU (prop);        } else {return '-' + islider.browser_prefix + '-' + prop;    }} else {return prop; }};/** * @param {String} prop * @param {HTMLELement} dom * @param {String} value * @public */islider.setstyle = function (DOM, prop, value) {Dom.style[islider.styl Eprop (prop, 1)] = value;};/  * * @type {Object} * * @param {htmlelement} dom the wrapper <li> element * @param {String} axis Animate Direction * @param {Number} scale Outer wrapper * @param {number} I wrapper ' index * @param {number} offset Move distance * @protect            ed */islider._animatefuncs = {normal: (function () {function Normal (DOM, axis, scale, I, offset) {        Islider.setstyle (DOM, ' transform ', ' Translatez (0) Translate ' + axis + ' (' + (offset + scale * (i-1) + ' px) ');        } normal.effect = Islider.styleprop (' transform ');    return normal; })()};

Information

CSS Secrets

Islider Line 250

How to detect CSS features

If we want to detect whether a CSS property supports

var dom = document.createelement (' P '), if (' Textshadow ' in Dom.style) {    alert (' Support Textshadow attribute ')}else {    alert (' Textshadow attribute ' not supported ')}

If we want to detect if the CSS3 property supports a value

var dom = document.createelement (' P ');d om.style.backgroundImage = ' linear-gradient (red, tan) '; Dom.style.backgroundImage) {    alert (' supports this attribute value ');} else {    alert (' Browser does not support this property value ')}

How to dynamically assign a CSS3 effect and support all major browsers

function Islider () {};/** * @returns {String} * @private */islider.transition_end_event = Null;islider.browser_prefix = Nu    ll; (function () {var e = document.createelement (' fakeelement '); [[' Webkittransition ', ' webkittransitionend ', ' WebKit '], [' transition ', ' transitionend ', null], [' Moz Transition ', ' transitionend ', ' Moz '], [' otransition ', ' otransitionend ', ' O ']].some (function (t) {if (E.            Style[t[0]]!== undefined) {islider.transition_end_event = t[1];            Islider.browser_prefix = t[2];        return true; }    });}) ();/** * @param {string} prop * @param {string} value * @returns {string} * @public */islider.styleprop = function (prop, ISDP) {if (Islider.browser_prefix) {if (!!        ISDP) {return islider.browser_prefix + IU (prop);        } else {return '-' + islider.browser_prefix + '-' + prop;    }} else {return prop; }};/** * @param {String} prop * @param {HTMLELement} dom * @param {String} value * @public */islider.setstyle = function (DOM, prop, value) {Dom.style[islider.styl Eprop (prop, 1)] = value;};/  * * @type {Object} * * @param {htmlelement} dom the wrapper <li> element * @param {String} axis Animate Direction * @param {Number} scale Outer wrapper * @param {number} I wrapper ' index * @param {number} offset Move distance * @protect            ed */islider._animatefuncs = {normal: (function () {function Normal (DOM, axis, scale, I, offset) {        Islider.setstyle (DOM, ' transform ', ' Translatez (0) Translate ' + axis + ' (' + (offset + scale * (i-1) + ' px) ');        } normal.effect = Islider.styleprop (' transform ');    return normal; })()};
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.