檢測瀏覽器對樣式的支援

來源:互聯網
上載者:User

真不知誰開了個壞頭,搞了什麼-xxx-首碼,CSS3上大量充斥著這樣的私人實現,因此檢測樣式變得非常麻煩。參考外國的一些實現,搞出自己的測試程式:

//by 司徒正美//http://www.cnblogs.com/rubylouvre/archive/2011/03/28/1998223.html           var getStyleProperty =  new function (css, el) {                    var prefixes = ['', '-ms-','-moz-', '-webkit-', '-khtml-', '-o-'];                    var reg_cap = /-([a-z])/g;                    return function(css, el){                        el = el || document.documentElement;                        var style = el.style, test;                        for (var i=0, l=prefixes.length; i 

好了,我們對以下CSS屬性進行測試:(發現IE9真是加班出來的鬼東西......)

log(getStyleProperty('column-count'));log(getStyleProperty('column-gap'));log(getStyleProperty('column-rule'));log(getStyleProperty('column-rule-color'));log(getStyleProperty('column-rule-style'));log(getStyleProperty('column-rule-width'));log(getStyleProperty('column-span'));log(getStyleProperty('column-width'));log(getStyleProperty('columns'));log(getStyleProperty('float-offset'));log(getStyleProperty('animation'));log(getStyleProperty('animation-delay'));log(getStyleProperty('animation-direction'));log(getStyleProperty('animation-duration'));log(getStyleProperty('animation-iteration-count'));log(getStyleProperty('animation-name'));log(getStyleProperty('animation-play-state'));log(getStyleProperty('animation-timing-function'));log(getStyleProperty('grid-columns'));log(getStyleProperty('grid-rows'));log(getStyleProperty('hanging-punctuation'));log(getStyleProperty('line-break'));log(getStyleProperty('punctuation-trim'));log(getStyleProperty('text-align-last'));log(getStyleProperty('text-autospace'));log(getStyleProperty('text-decoration'));log(getStyleProperty('text-decoration-color'));log(getStyleProperty('text-decoration-line'));log(getStyleProperty('text-decoration-skip'));log(getStyleProperty('text-decoration-style'));log(getStyleProperty('text-emphasis'));log(getStyleProperty('text-emphasis-color'));log(getStyleProperty('text-emphasis-position'));log(getStyleProperty('text-emphasis-style'));log(getStyleProperty('text-justify'));log(getStyleProperty('text-outline'));log(getStyleProperty('text-shadow'));log(getStyleProperty('text-underline-position'));log(getStyleProperty('white-space-collapsing'));log(getStyleProperty('word-break'));log(getStyleProperty('word-wrap'));log(getStyleProperty('target'));log(getStyleProperty('target-name'));log(getStyleProperty('target-new'));log(getStyleProperty('target-position'));log(getStyleProperty('border-image'));log(getStyleProperty('border-image-outset'));log(getStyleProperty('border-image-repeat'));log(getStyleProperty('border-image-slice'));log(getStyleProperty('border-image-source'));log(getStyleProperty('border-image-width'));log(getStyleProperty('border-radius'));log(getStyleProperty('box-align'));log(getStyleProperty('box-decoration-break'));log(getStyleProperty('box-direction'));log(getStyleProperty('box-flex'));log(getStyleProperty('box-lines'));log(getStyleProperty('box-ordinal-group'));log(getStyleProperty('box-orient'));log(getStyleProperty('box-pack'));log(getStyleProperty('box-shadow'));log(getStyleProperty('rotation'));log(getStyleProperty('rotation-point'));log(getStyleProperty('marquee-direction'));log(getStyleProperty('marquee-loop'));log(getStyleProperty('marquee-play-count'));log(getStyleProperty('marquee-speed'));log(getStyleProperty('marquee-style'));log(getStyleProperty('overflow-style'));log(getStyleProperty('box-sizing'));log(getStyleProperty('nav-index'));log(getStyleProperty('nav-x'));log(getStyleProperty('outline'));log(getStyleProperty('outline-color'));log(getStyleProperty('outline-offset'));log(getStyleProperty('outline-style'));log(getStyleProperty('outline-width'));log(getStyleProperty('resize'));log(getStyleProperty('text-overflow'));log(getStyleProperty('transform'));log(getStyleProperty('transform-origin'));log(getStyleProperty('transform-style'));log(getStyleProperty('background-clip'));log(getStyleProperty('background-origin'));log(getStyleProperty('background-size'));log(getStyleProperty('transition'));log(getStyleProperty('transition-delay'));log(getStyleProperty('transition-duration'));log(getStyleProperty('transition-property'));log(getStyleProperty('transition-timing-function'));

點我執行代碼

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.