【css 】hank 寫法

<!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>
    <title>無標題頁</title>
    <!--CSS兼容IE6 IE7 IE8 IE9 Firefox的總結-->
    <style type="text/css">
        #div
        {
            /*  一:*各類瀏覽器css hack兼容狀況*/
            width:200px;
            height:200px;
            background: red;                   /* 全部瀏覽器*/
            /*  background: black!important;   /* 有ie7,ie8,ie9,,firefox,chrome支持 */
            /*  _background: yellow;           /* 只有ie6支持 */
            /*  +background:yellow;            /* 只有ie6,ie7支持 */
            /*  *+background:yellow;           /* 只有ie6,ie7支持 */
            /*  *background:black;             /* 只有ie6,ie7支持 */
            /*  background:yellow\9;           /* 有ie6,ie7,ie8,ie9支持 */
            /*  background:black\0;            /* 有ie8,ie9支持 */
        }
         /* body:nth-of-type(1) div            /* 有ie9,firefox,chrome,Safari支持 */
          /*{
              width: 200px;
            height: 200px;
            background: red;
          }*/
          
         /* 二:其餘說明
            一、若是你的頁面對IE7兼容沒有問題,又不想大量修改現有代碼,同時又能在IE8中正常使用,微軟聲稱,
              開發商僅須要在目前兼容IE7的網站上添加一行代碼便可解決問題,此代碼以下: 
              <meta http-equiv="x-ua-compatible" content="ie=7" /> 
            二、body:nth-of-type(1) 若是這樣寫,表示全局查找body,將會對應第一個<body>。 
            三、還有其餘寫法,好比: 
               *html #test{}或者 *+html #test{} 
            四、*+html 對IE7的hack 必須保證HTML頂部有以下聲明: 
               http://www.w3.org/TR/html4/loose.dtd 
            五、順序:Firefox、IE八、IE七、IE6依次排列。 
                小知識:什麼是CSS hack? 
              因爲不一樣的瀏覽器,好比IE六、IE七、IE八、Firefox等,對CSS的解析認識不同,所以會致使生成的頁面效果不同,得不到咱們所須要的頁面效果。 
              這個時候咱們就須要針對不一樣的瀏覽器去寫不一樣的CSS,讓它可以同時兼容不一樣的瀏覽器,能在不一樣的瀏覽器中也能獲得咱們想要的頁面效果。 
              這個針對不一樣的瀏覽器寫不一樣的CSS code的過程,就叫CSS hack,也叫寫CSS hack。*/


    </style>
</head>
<body>
    <div id="div1">
    </div>
</body>
</html>
相關文章
相關標籤/搜索