[CSS Hack]解決IE6、IE7、IE8、Firefox的瀏覽器安全色問題

來源:互聯網
上載者:User

原文連結:點擊開啟連結

一、如果你的頁面對IE7相容沒有問題,又不想大量修改現有代碼,同時又能在IE8中正常使用,微軟聲稱,開發商僅需要在目前相容IE7的網站上添加一行代碼即可解決問題,此代碼如下:

<meta http-equiv="x-ua-compatible" content="ie=7" />

二、區分各瀏覽器的CSS hack

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>區別IE6、IE7、IE8、FireFox的CSS hack</title>

<style type="text/css">

<!--

#test,#note{

margin:0 auto;

text-align:center; 

}

#test {

width:200px;

height:30px;

border: 1px solid #000000;

color:#fff;

line-height:30px;

}

.color{

background-color: #CC00FF; /*所有瀏覽器都會顯示為紫色*/

background-color: #FF0000\9; /*IE6、IE7、IE8會顯示紅色*/

*background-color: #0066FF; /*IE6、IE7會變為藍色*/   

_background-color: #009933; /*IE6會變為綠色*/

}

-->

</style>

</head>

<body>

<div id="test" class="color">測試方塊 不同的瀏覽器顯示不同的顏色 </div>

<div id="note">

<strong style="color:#009933">IE6</strong>

<strong style="color:#0066FF">IE7、360、傲遊</strong>

<strong style="color:#FF0000">IE8</strong>

<strong style="color:#CC00FF">所有非IE,如FireFox</strong>

</div>

</body>

</html>

相關文章

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.