調(diào)用CSS hack區(qū)分不同瀏覽器
針對(duì)不同的瀏覽器寫不同的CSS code的過(guò)程,就叫CSS hack,也叫寫CSS hack,本文向大家介紹一下使用CSS hack區(qū)別不同瀏覽器的方法,主要瀏覽器有IE6,IE7,F(xiàn)irefox等,相信本文介紹一定會(huì)讓你有所收獲。
使用CSS hack區(qū)別不同瀏覽器
CSS hack由于不同的瀏覽器,比如Internet Explorer 6,Internet Explorer 7,Mozilla Firefox等,對(duì)CSS的解析認(rèn)識(shí)不一樣,因此會(huì)導(dǎo)致生成的頁(yè)面效果不一樣,得不到我們所需要的頁(yè)面效果。 這個(gè)時(shí)候我們就需要針對(duì)不同的瀏覽器去寫不同的CSS,讓它能夠同時(shí)兼容不同的瀏覽器,能在不同的瀏覽器中也能得到我們想要的頁(yè)面效果。
CSS hack區(qū)別IE6與Firefox:
background:orange;*background:blue;
CSS hack區(qū)別IE6與IE7:
background:green !important;background:blue;
CSS hack區(qū)別IE7與Firefox:
background:orange; *background:green;
CSS hack區(qū)別Firefox,IE7,IE6:
background:orange;*background:green !important;*background:blue;
◆注:IE都能識(shí)別*;標(biāo)準(zhǔn)瀏覽器(如Firefox)不能識(shí)別*;
IE6能識(shí)別*,但不能識(shí)別 !important,
IE7能識(shí)別*,也能識(shí)別!important;
Firefox不能識(shí)別*,但能識(shí)別!important;
◆另外再補(bǔ)充一個(gè),下劃線"_",IE6支持下劃線,IE7和firefox均不支持下劃線。
于是大家還可以這樣來(lái)區(qū)分IE6,IE7,firefox:
background:orange;*background:green;_background:blue;
注:不管是什么方法,書寫的順序都是firefox的寫在前面,IE7的寫在中間,IE6的寫在最后面。
【編輯推薦】
- CSS hack:實(shí)現(xiàn)IE6、IE7、Firefox兼容
- CSS HACK和瀏覽器兼容問(wèn)題的解決方法
- 深入探究DIV CSS布局中position屬性用法
- CSS屬性display:inline-block使用揭秘
- Firefox、IE7、IE6瀏覽器兼容問(wèn)題概念解析