CSS——瀏覽器安全色性處理(PC)

來源:互聯網
上載者:User

標籤:

解決網頁在IE7中的相容情況:*

如:.content{height:30px;/*正常顯示效果*/    *height:20px;/*IE7顯示效果*/}

解決網頁在IE8中的相容情況:

在網頁頭部做個判斷即可。

<!DOCTYPE HTML>
<!--[if IE 8 ]> <html class="ie8" > <![endif]-->
<!--[if ! IE 8]>
<html>
<!--<![endif]-->

<head>

如果是在IE8瀏覽器下就用類名以.ie8為首碼的樣式。

如:.content{height:30px;}/*其他瀏覽器中顯示的樣式*/

  .ie8 .content{height:20px;}/*IE8中顯示的樣式*/

解決網頁在Firefox中的相容情況:

@-moz-document url-prefix(){ /*在這裡寫必要的樣式*/ }

註:這個是解決所有Firefox瀏覽器不相容情況的方法。

解決網頁在IE9中的相容情況:

\9\0(只使用於IE9,其他瀏覽器不識別)

解決網頁在IE10中的相容情況:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {   

  .hacktest { background-color:green; } /* for IE10+ 此寫法可以適配到高對比和預設模式,故可覆蓋所有ie10的模式 */  

}  

選取器首碼法

選取器首碼法是針對一些頁面表現不一致或者需要特殊對待的瀏覽器,在CSS選取器前加上一些只有某些特定瀏覽器才能識別的首碼進行hack。

目前最常見的是

*html *首碼只對IE6生效*+html *+首碼只對IE7生效@media screen\9{...}只對IE6/7生效@media \0screen {body { background: red; }}只對IE8有效@media \0screen\,screen\9{body { background: blue; }}只對IE6/7/8有效@media screen\0 {body { background: green; }} 只對IE8/9/10有效@media screen and (min-width:0\0) {body { background: gray; }} 只對IE9/10有效@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {body { background: orange; }} 只對IE10有效等等

CSS——瀏覽器安全色性處理(PC)

聯繫我們

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