CSS Hack大全-教你如何區分出IE6-IE10、FireFox、Chrome、Opera,ie6-ie10chrome

來源:互聯網
上載者:User

CSS Hack大全-教你如何區分出IE6-IE10、FireFox、Chrome、Opera,ie6-ie10chrome

今天把一些常用的CSS Hack整理了一下,包括常用的IE hack以及Firefox、Chrome、Opera瀏覽器的Hack,並把這些CSS Hack綜合的一起,寫了一個小的瀏覽器測試器

 

現在的瀏覽器IE6-IE10、Firefox、Chrome、Opera、Safari。。。數量眾多,可謂百家爭鳴,對使用者來說有了很多的可選擇型,不過這可就苦了Web前端開發人員了。
今天把一些常用的CSS Hack整理了一下,包括常用的IE hack以及Firefox、Chrome、Opera瀏覽器的Hack,並把這些CSS Hack綜合的一起,寫了一個小的瀏覽器測試器。:

下面就來看一下代碼吧:

html部分:

 

代碼如下:
<div class="content">
    <div class="test"></div>
    <div class="txt">
        <p>IE6下背景顏色:<span class="ie6">Hack部分的代碼吧,布局的就不貼了:

 

代碼如下:
.content .test {
    width: 200px;
    height: 200px;
    background: #f60; /*all*/
    background: #06f9; /*IE*/
    *background: #666; /*IE6,7*/
    _background: #ccc; /*IE6*/
}

/* webkit and opera */
@media all and (min-width:0){
    .content .test {
        background: #0f0;
    }
}

/* webkit */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    .content .test {
        background: #ff0;
    }
}

/*FireFox*/
@-moz-document url-prefix() {
    .content .test {
        background: #f0f;
    }
}

/*IE9+*/
@media all and (min-width:0) {
    .content .test{
        background: #f009;
        }
}

/*IE10+*/
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .content .test {
        background: #0ff;
    }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.