css關於瀏覽器安全色問題的解析

來源:互聯網
上載者:User
這篇文章分享給大家的內容是關於css關於瀏覽器安全色問題的解析,內容很有參考價值,希望可以幫到有需要的小夥伴。

一、Firefox
1. <input type="date" /> 失效
hack:採用jquery UI:datepicker外掛程式。
(1)下載外掛程式,放置在專案檔夾中;
(2)在所需頁面引入,如:

 <script src="jslib/plugins/datepicker/bootstrap-datepicker.js"></script>

此script與頁面所需的對應的js位置不分先後;
(3)點擊觸發pick事件,func(pic);
調用$("#datepicker").datepicker() ;
帶參數的寫法:

$("#datepicker").datepicker({    numberOfMonth: 3,     // 一排3個    numberOfMonth: [3,2], // 三排每排2個    }) ;

二、ie8
1.圓角:border-radius失效
hack:使用一些能使ie相容css3新屬性的外掛程式,這裡介紹一下pie.htc 。
(1)下載pie.htc ;http://css3pie.com/
(2)部署在你的專案檔中,我習慣是放在js下面,不過,就像官網說的
“It doesn't matter where exactly, as long as you know where it is.”;
(3)寫樣式並追加相容,如:

a.level0 span.button {    width:10px;    height:10px;    background:#999;    border-radius:50%;    -webkit-border-radius:50%;    -moz-border-radius:50%;    behavior:url(view/js/pie.htc)    //值得注意的是,追加相容的路徑並不是相對於當前的css檔案,    //而是相對應的html/jsp檔案,個人覺得官網只有說明沒有樣本不太好。}

2.漸層:background-image:linear-gredient()失效
hack1:使用相容外掛程式。
方法同上的前兩步(1)、(2)
(3)寫樣式並追加相容,如:

nav{    background:linear-gradient(#8fb8ff 0%, #fff 100%);    background:-webkit-linear-gradient(#8fb8ff 0%, #fff 100%);    background:-moz-linear-gradient(#8fb8ff 0%, #fff 100%);    -pie-background: linear-gradient(#8fb8ff 0%, #fff 100%); //ie 6-9     behavior: url(view/js/pie.htc);}

hack2:使用相容文法。

background:linear-gradient(#8fb8ff 0%, #fff 100%);background:-webkit-linear-gradient(#8fb8ff 0%, #fff 100%);background:-moz-linear-gradient(#8fb8ff 0%, #fff 100%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000',endColorstr='#E5000000',GradientType=0 ); //GradientType: 0垂直漸層 , 1水平漸層

以上兩種方法雜不同的情境中都各有各的優點和缺點,在項目開發中,
可以都試一下採用相容更好的一種即可。

3.結構偽類別選取器:nth-of-type( )失效
hack:ie8支援first-child,變更一下代碼。

a.level0 span:nth-of-type(1) ——>a.level0 span:first-childa.level0 span:nth-of-type(2)——>a.level0 span:first-child+span //第二個子節點a.level0 span:nth-of-type(3)——>a.level0 span:first-child+span+span//第三個子節點//以此類推

4.盒子陰影:box-shadow失效
hack:pie.htc

p{    wdith:100px;    height:100px;    background:#fff;     //儘管背景是白色,最好還是設定一下,不然相容後的效果可能會不太理想    box-shadow:10px 10px 10p #aaa;    behavior:url(view/js/pie.htc)}

5.透明色rgba()失效
hack:pie.htc

.contaniner{    width:100px;    height:100px;    background:rgba(0,0,0,0.5);    -pie-background:rgba(0,0,0,0.5);    behavior:url(view/js/pie.htc);}

6.<input type="checkbox" /> 有預設border
hack:在css檔案中控制一下就好了,如

input[type="checkbox"] {    border:none;}

7.順便介紹一下過濾器filter,filter是一種用來過濾不同瀏覽器的hack類型。
(1)9 :所有IE瀏覽器都支援
(2)0 :IE8、IE9支援,opera部分支援
(3)90 :IE8部分支援、IE9支援
(4)09 :IE8、IE9支援
如:

background:#0f0;//chrome 、firefox 顯示綠色background\0:#00f ;//ie顯示藍色
相關文章

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.