亚洲AV无码乱码在线观看不卡|最新大伊香蕉精品视频在线|亚洲不卡av一区二区|国产美女无遮挡免费

登錄論壇 | 注冊會員 設為首頁 | 收藏本站
當前位置 : 首頁>軟件學院>程序開發(fā)>CSS>正文
 
關于CSS HACK 解決兼容的寫法

http://www.yibo1263.com 2010-5-31 7:45:15  來源:東北IT網(wǎng)  編輯:葉子
 

經(jīng)濟實惠型寫法:注重單獨的HACK。 IE的HACK比較多,選擇省力易記的屬性HACK;其他瀏覽器HACK少,選擇塊狀的選擇器HACK(推薦)


.sofish{
padding:10px;
padding:9px\9; /* all ie */
padding:8px\0; /* ie8-9 目前應用于IE8的單獨hack,情況比較少 */
*padding:5px; /* ie6-7 */
+padding:7px; /* ie7 */
_padding:6px; /* ie6 */
}

/* webkit and opera */
@media all and (min-width: 0px){ .sofish{padding:11px;} }

/* webkit */
@media screen and (-webkit-min-device-pixel-ratio:0){ .sofish{padding:11px;} }

/* opera */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { .sofish{padding:11px;} }

/* firefox * /
@-moz-document url-prefix(){ .sofish{padding:11px;}} /* all firefox */
html>/**/body .sofish, x:-moz-any-link, x:default { padding:11px; } /* newest firefox */
準完美主義寫法:配合IE注釋,一律采用選擇器HACK(選擇性推薦)


HTML: 添加body class:

<!--[if IE6]--><![endif]-->
<!--[if IE7]--><![endif]-->
<!--[if IE8]--><![endif]-->
<!--[if IE9]--><![endif]-->
<!--[if !IE]--><![endif]-->

.sofish{padding:10px;}
.non-ie .sofish{padding:12px;}
.ie9 .sofish{padding:9px;}
.ie8 .sofish{padding:8px;}
.ie7 .sofish{padding:7px;}
.ie6 .sofish{padding:6px;}

/* webkit and opera */
@media all and (min-width: 0px){ .sofish{padding:11px;} }

/* webkit */
@media screen and (-webkit-min-device-pixel-ratio:0){ .sofish{padding:11px;} }

/* opera */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { .sofish{padding:11px;} }

/* firefox * /
@-moz-document url-prefix(){ .sofish{padding:11px;}} /* all firefox */
html>/**/body .sofish, x:-moz-any-link, x:default { padding:11px; } /* newest firefox */
[/css]

然后,從第二種方式我們也可以發(fā)現(xiàn)。把IE注釋用在body class上,而不是添加單獨的或者@import會是更好的選擇。雖然分文件也是一種不錯的選擇,但了為頁面加載速度,HTTP請求一個都不能浪費。


 

至于利用JS或者后端程序來判斷,除非你有足夠的資源,除非你解決不了(90%不會發(fā)生),不然,并不推薦用。附上一個表(via),可以參考參考:


 

六:全面的IE6+ / Firefox / Webkit / Opera CSS HACK列表:


[cc lang="css"]
/***** Selector Hacks ******/

/* IE6 and below */
* html #uno { color: red }

/* IE7 */
*:first-child+html #dos { color: red }

/* IE7, FF, Saf, Opera */
html>body #tres { color: red }

/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body #cuatro { color: red }

/* Opera 9.27 and below, safari 2 */
html:first-child #cinco { color: red }

/* Safari 2-3 */
html[xmlns*=""] body:last-child #seis { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #siete { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #ocho { color: red }

/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
#diez { color: red }
}

/* iPhone / mobile webkit */
@media screen and (max-device-width: 480px) {
#veintiseis { color: red }
}

/* Safari 2 - 3.1 */

本新聞共3頁,當前在第2頁  1  2  3  

 
收藏】【打印】【進入論壇
  相關文章:

·CSS3 Media Queries 詳解
·CSS實例教程:非浮動區(qū)域設置寬度
·css的效率和瀏覽器渲染的速度
·小議使用“完整”的CSS的缺點
·關于CSS不透明的詳細介紹 
·CSS中設置段落間距的方法
·用css網(wǎng)站布局之十步實錄
·DIV+CSS布局代碼精簡對SEO的影響 
·CSS教程:網(wǎng)頁中英文字體的設置 
·css3文本陰影屬性text-shadow說明 
·css3陰影屬性box-shadow注意事項 

 
 
 
 
最新文章

中關村艷照門女主角詳記錄高清組圖 
大連護士門大尺度艷照高清組圖
iPhone女孩微博爆紅 最寶貴東西換iPhon
反恐精英之父內(nèi)維爾:改變電腦游戲銷售
團購網(wǎng)站黎明之前:中國市場慘烈廝殺不
團購鼻祖Groupon中國揭秘:快與慢的商業(yè)
Spil Games發(fā)布新的品牌形象
1800配置一臺主機 不要顯示器
聯(lián)想V360筆記本模特寫真
愛國者第四代移動硬盤將面市、低電壓保

 
推薦文章
1
2
3
4
5
6
7
8
9
10
iPhone女孩微博爆紅 最寶貴東西換
大連護士門大尺度艷照高清組圖
中關村艷照門女主角詳記錄高清組
蘋果員工中毒門
宮如敏不雅照瘋傳 看張馨予韓一菲
深耕市場 永續(xù)經(jīng)營——專訪百腦匯
優(yōu)派專業(yè)電子書 讓您回家旅途多姿
揭曉百萬大獎三星bada魅力綻放中
大明龍權(quán)“江湖英雄會”全國PK大
永恒之塔校園達人挑戰(zhàn)賽完美落幕
八卦圖解 More>>
iPhone女孩微博爆紅 最寶貴東西換 大連護士門大尺度艷照高清組圖
中關村艷照門女主角詳記錄高清組 宮如敏不雅照瘋傳 看張馨予韓一菲