Home > Web Front-end > CSS Tutorial > CSS Hack Encyclopedia - Teach you how to distinguish IE6-IE10, FireFox, Chrome, Opera

CSS Hack Encyclopedia - Teach you how to distinguish IE6-IE10, FireFox, Chrome, Opera

高洛峰
Release: 2016-12-24 15:38:31
Original
1075 people have browsed it

The current browsers are IE6-IE10, Firefox, Chrome, Opera, and Safari. . . There are so many, it can be said that a hundred schools of thought are contending, and there are many options for users, but this is a pain for Web front-end developers.
Today I sorted out some commonly used CSS Hacks, including commonly used IE hacks and Hacks for Firefox, Chrome, and Opera browsers. I combined these CSS Hacks and wrote a small browser tester.

Let’s take a look at the code:

html part:

<div class="content">
    <div class="test"></div>
    <div class="txt">
        <p>IE6下背景颜色:<span class="ie6" style="background-color: #ccc;">#ccc</span></p>
        <p>IE7下背景颜色:<span class="ie7" style="background-color: #666;">#666</span></p>
        <p>IE8下背景颜色:<span class="ie8" style="background-color: #06f;">#06f</span></p>
        <p>IE9下背景颜色:<span class="ie9" style="background-color: #f00;">#f00</span></p>
        <p>IE10下背景颜色:<span class="ie10" style="background-color: #0ff;">#0ff</span></p>
        <p>webkit,Safari,Chrome下背景颜色:<span class="webkit-safari-gg" style="background-color: #ff0;">#ff0</span></p>
        <p>FireFox下背景颜色:<span class="firefox" style="background-color: #f0f;">#f0f</span></p>
        <p>Opera下背景颜色:<span class="opera" style="background-color: #0f0;">#0f0</span></p>
    </div>
</div>
Copy after login

CSS part. In this part, only the Hack part of the code will be posted, and the layout will not be posted:

.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;
    }
}
Copy after login


More CSS Hack Collection -Teach you how to distinguish IE6-IE10, FireFox, Chrome, and Opera. For related articles, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template