Detecting flex-wrap support in browsers

前端 未结 3 1868
花落未央
花落未央 2020-12-03 12:03

I am working on a project in which I have a responsive grid which I have achieved using flex wrap property. Since I am supporting IE9 and lower versions of Firefox, version

3条回答
  •  死守一世寂寞
    2020-12-03 12:32

    Expanding on @AndresTet's answer, if you do not want a complete modernizr build, you can create a custom one, or extract and refactor the relevant flexbox tests, which seem to be:

    function testPropsAll(prop, prefixed, elem) {
    
        var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
            props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
    
        if (is(prefixed, "string") || is(prefixed, "undefined")) {
            return testProps(props, prefixed);
    
        } else {
            props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
            return testDOMProps(props, prefixed, elem);
        }
    }
    
    tests['flexbox'] = function() {
        return testPropsAll('flexWrap');
    };
    
    tests['flexboxlegacy'] = function() {
        return testPropsAll('boxDirection');
    };
    

提交回复
热议问题