成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

IE7和IE8的CSS樣式八大差異

開發 前端
本文向大家描述一下IE7和IE8的CSS樣式八大差異,Microsoft官方并未提供關于IE7及IE8的CSS差異說明文件,只是說IE8目前更趨近于CSS2.1而非CSS2.0,這里規類出8個最常見的差異供讀者們參考。

你對IE7和IE8的CSS樣式八大差異是否了解,這里和大家分享一下,IE7所設計的網頁,在IE8上的呈現會有所出入,所幸拜IE7相容檢視功能所賜,目前因使用IE8而導致版面錯誤的網站并不多。

IE7和IE8的CSS樣式八大差異

InternetExplorer8預設是以CSS2.1為標準,并修正了許多InternetExplorer7的CSSBug,這意味著有一部份以往依據IE7所設計的網頁,在IE8上的呈現會有所出入,所幸拜IE7相容檢視功能所賜,目前因使用IE8而導致版面錯誤的網站并不多。但一值依賴IE7相容檢視功能并非長久之計,盡早將網站修改為IE8相容才是長久之計,因為畢竟CSS是持續更新的,現在不改,日后大修的機會就更大。不幸的是,Microsoft官方并未提供關于IE7及IE8的CSS差異說明文件,頂多只是告訴我們IE8目前更趨近于CSS2.1而非CSS2.0,因此筆者在造訪許多網站后,規類出8個最常見的差異供讀者們參考。

1、起始座標位置

先天上,IE7與IE8在預設網頁版面的起始位置就不同,以下面的代碼來說,在IE7及IE8上啟始的位置就有差異。
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <divstyledivstyle="height:100px;width:200px;border:solid1pxblack"> 
  9. <div> 
  10. <ahrefahref="http://www.hinet.net">Hineta> 
  11. div> 
  12. div> 
  13. body> 
  14. html> 
  15.  

不過由于是整個偏移,對網頁的影響相當小。

2、DIV中的P

下面的執行結果呈現了IE7及IE8在處理DIV中的P之差異性。
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <divstyledivstyle="height:100px;width:200px;border:solid1pxblack"> 
  9. <div> 
  10. <p>TESTFontp> 
  11. div> 
  12. div> 
  13. body> 
  14. html> 
  15.  

很明顯的,IE8中對于DIV中的P預設位置與IE7不同,IE7是將margin-top預設為0px,排在最上方,,IE8卻未預設margin-top,
解決方法是將margin-top加上。
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <divstyledivstyle="height:100px;width:200px;border:solid1pxblack"> 
  9. <div> 
  10. <pstylepstyle="margin-top:0px">TESTFontp> 
  11. div> 
  12. div> 
  13. body> 
  14. html> 
  15. (IE8Withmargin-top)  
  16.  

 #p#3、負數margin

許多網頁設計師常常以負數的margin來定位HTML元素的位置,目的是讓該元素與圖形對齊,IE7及IE8對于負數的解釋有蠻大的差異性。
程式4
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <divstyledivstyle="height:100px;width:200px;border:solid1pxblack"> 
  9. <divstyledivstyle="background-color:Red;margin:-5px6px7px8px"> 
  10. <ahrefahref="http://www.hinet.net">Hineta> 
  11. div> 
  12. div> 
  13. body> 
  14. html> 
  15.  

由比較圖可看出,IE7遭遇負數時,并不會移出DIV的范圍,而IE8會,在筆者撰寫本文之時,大多數的不相容IE8網頁錯誤都源自于此。

4、TableWithBorderStyle

元素的Layout在每個瀏覽器上都會有些許差異的表現,下面的代碼是一個在IE7及IE8上呈現相異的范例。Table
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <tablestyletablestyle="border:double7pxgreen"> 
  9. <tr> 
  10. <tdstyletdstyle="border:double1pxgreen">atd> 
  11. <tdstyletdstyle="border:double1pxgreen">atd> 
  12. <tdstyletdstyle="border:double1pxgreen">atd> 
  13. tr> 
  14. <tr> 
  15. <tdstyletdstyle="border:double1pxgreen">atd> 
  16. <tdstyletdstyle="border:double1pxgreen">atd> 
  17. <tdstyletdstyle="border:double1pxgreen">atd> 
  18. tr> 
  19. <tr> 
  20. <tdstyletdstyle="border:double1pxgreen">atd> 
  21. <tdstyletdstyle="border:double1pxgreen">atd> 
  22. <tdstyletdstyle="border:double1pxgreen">atd> 
  23. tr> 
  24. table> 
  25. body> 
  26. html> 
  27.  

很明顯的,IE7的border寬度計算比IE8高,不過由于這是整體偏移,加上我們很少會設定太大的border寬度,影響程度幾乎等于0。#p#

5、bottom、top

當使用絕對位置時,IE7與IE8會產生些許的偏移,這些偏移是整體性的,所以影響很小
例子:
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <divstyledivstyle="height:100px;width:200px;border:solid1pxblack"> 
  9. <divstyledivstyle="background-color:Red;bottom:5px;top:5px;position:absolute;height:40px"> 
  10. TEST  
  11. div> 
  12. div> 
  13. body> 
  14. html> 
  15.  

很難看出來吧,因為偏移很小,不過確實是偏移了。

6、li+float

UL、LI加上float,在IE7于IE8有相當大的差異,見:
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <div> 
  9. <div> 
  10. <ul> 
  11. <listylelistyle="cursor:hand;float:left;"> 
  12. TEST1li> 
  13. <listylelistyle="cursor:hand;float:left;"> 
  14. TEST2li> 
  15. <listylelistyle="cursor:hand;float:left;"> 
  16. TEST3li> 
  17. <listylelistyle="cursor:hand;float:left;"> 
  18. TEST4li> 
  19. <listylelistyle="cursor:hand;float:left;"> 
  20. TEST5li> 
  21. ul> 
  22. div> 
  23. div> 
  24. body> 
  25. html> 
  26.  

在IE7上,LI的項目符號被取消了,而在IE8上則正常顯示,但卻因為是float,所以后面的項目符號蓋到前一項目了。修改為程式8的模樣后
,兩者就趨近相同了。

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <div> 
  9. <div> 
  10. <ulstyleulstyle="list-style-type:none"> 
  11. <listylelistyle="cursor:hand;float:left;"> 
  12. TEST1li> 
  13. <listylelistyle="cursor:hand;float:left;"> 
  14. TEST2li> 
  15. <listylelistyle="cursor:hand;float:left;"> 
  16. TEST3li> 
  17. <listylelistyle="cursor:hand;float:left;"> 
  18. TEST4li> 
  19. <listylelistyle="cursor:hand;float:left;"> 
  20. TEST5li> 
  21. ul> 
  22. div> 
  23. div> 
  24. body> 
  25. html> 
  26.  

在嘗試尋找CSS相異點時,許多網站都有這類問題,因為我們常用這種手法來處理頁簽類的顯示。
PS:list-style-type在IE7時,只要li是float,就會被完全忽略。#p#

7、div+heightwithulandimage

當DIV設定了固定大小,而內容超出所定大小,然后后方跟著IMG時,在IE7及IE8會有相當大的差異。
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <div> 
  9. <divstyledivstyle="width:300px;height:22px;margin-top:5px"> 
  10. <ulstyleulstyle="list-style-type:none"> 
  11. <listylelistyle="cursor:hand;float:left;"> 
  12. TEST1li> 
  13. <listylelistyle="cursor:hand;float:left;"> 
  14. TEST2li> 
  15. <listylelistyle="cursor:hand;float:left;"> 
  16. TEST3li> 
  17. <listylelistyle="cursor:hand;float:left;"> 
  18. TEST4li> 
  19. <listylelistyle="cursor:hand;float:left;"> 
  20. TEST5li> 
  21. <listylelistyle="cursor:hand;float:left;"> 
  22. TEST6li> 
  23. ul> 
  24. div> 
  25. <ahrefahref="http://www.hinet.net>"> 
  26. <imgsrcimgsrc="21565.jpg"width="300px"height="200px"/> 
  27. a> 
  28. div> 
  29. body> 
  30. html> 
  31.  

很明顯的,IE7會尊重DIV所制定的大小來安排后面的IMG位置,所以在圖14上看不出有何問題,但是在IE8里,當內容超出制定大小時,
IMG位置會順移開,所以就造成了此問題。在實務上,這算是相當常見的相容性錯誤。
解決方法很簡單,將要被蓋住的那個LI移掉就好了,這本來就是錯誤的設計。

8、p的子控件對齊

有些網頁設計師習慣使用P加上子控件來描繪單行輸入+按紐的樣式,這些網頁在IE8上會有或許的差異,如果里面使用的IMG太多,
差異就會大到很難忽視。
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. head> 
  7. <body> 
  8. <p> 
  9. <inputtypeinputtype="text"/> 
  10. <imgsrcimgsrc="add2.png"height="16px"width="16px"/> 
  11. p> 
  12. body> 
  13. html> 
  14.  

很明顯,IE7會對IMG置中于P,但IE8不會。這類問題很難解決,需要透過CSS判斷IE版本來提供不同的CSS,讓兩者趨近相同。
 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <title>title> 
  6. 2009-08-13 10:12:07

    IE的CSS Bug

2010-08-18 10:37:16

IE6IE7IE8

2010-09-15 11:08:48

CSSIE6IE7

2010-09-08 16:59:48

CSS兼容IE7IE8

2010-08-19 09:24:20

CSS兼容IE7IE8

2010-08-18 10:24:51

IE6IE7IE8

2010-08-17 15:38:49

CSS兼容IE7IE8

2010-09-16 13:17:31

IE6IE7IE8

2011-03-08 11:14:35

IE7、IE8、IE

2011-06-03 15:41:27

CSS HACK

2010-08-18 15:57:14

IE6IE7IE8

2010-08-19 14:33:18

2010-08-20 13:15:54

IE6IE7IE8

2010-09-15 10:14:19

IE7IE8兼容CSS

2010-09-15 10:25:18

IE7IE8CSS兼容性

2010-08-19 10:56:55

JSIE6IE7

2010-09-16 13:33:47

IE6IE7IE8

2010-08-20 13:08:41

IE6IE7IE8

2010-08-19 14:19:12

IE6IE7IE8

2010-08-17 15:33:28

CSS兼容IE7IE8
點贊
收藏

51CTO技術棧公眾號

業務
速覽
在線客服
主站蜘蛛池模板: 久久神马 | 亚洲精品成人在线 | 欧美精品一区二区三区蜜桃视频 | 天天操天天射综合网 | av中文字幕在线播放 | 国产精品美女久久久久久久久久久 | 亚洲综合五月天婷婷 | 国产成人av一区二区三区 | 91精品麻豆日日躁夜夜躁 | 一级毛片视频免费观看 | 国产小视频在线观看 | 国产精品久久久亚洲 | 久久综合狠狠综合久久综合88 | 国产精品久久久久久影视 | 亚洲综合国产 | 国产高清在线 | 国产精品中文字幕在线 | 精品美女久久久久久免费 | 有码在线 | 精品无码久久久久久国产 | 99热这里有精品 | 免费一看一级毛片 | 精品久久久网站 | 久久伊人一区 | 午夜影视在线观看 | 国产精品一区二区视频 | 黑人中文字幕一区二区三区 | 九九久久国产精品 | 2019天天干天天操 | 91人人澡人人爽 | 久久高清精品 | 亚洲一区日韩 | 男女国产网站 | 久久99精品久久久久久 | 剑来高清在线观看 | 日韩精品一区二 | 一区二区三区免费 | 欧美日韩精品久久久免费观看 | 9999国产精品欧美久久久久久 | 青青草社区 | 亚洲欧美日韩电影 |