The best way of checking for -moz-border-radius support

前端 未结 7 450
日久生厌
日久生厌 2021-01-02 04:54

I wanted some of those spiffy rounded corners for a web project that I\'m currently working on.

I thought I\'d try to accomplish it using javascript and not CSS in a

7条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 04:58

    I know this is an older question, but it shows up high in searches for testing border-radius support so I thought I'd throw this nugget in here.

    Rob Glazebrook has a little snippet that extends the support object of jQuery to do a nice quick check for border-radius support (also moz and web-kit).

    jQuery(function() {
    jQuery.support.borderRadius = false;
    jQuery.each(['BorderRadius','MozBorderRadius','WebkitBorderRadius','OBorderRadius','KhtmlBorderRadius'], function() {
        if(document.body.style[this] !== undefined) jQuery.support.borderRadius = true;
        return (!jQuery.support.borderRadius);
    }); });
    

    Attribution

    That way, if there isn't support for it you can fall back and use jQuery to implement a 2-way slider so that other browsers still have a similar visual experience.

提交回复
热议问题