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

IE CSS Bug系列:32樣式限制

開發 前端
IE 瀏覽器不支持很多 CSS 屬性是出了名的,即便在支持的部分中,也是有很多 Bug 的。Zoffix Znet 整理了 IE 中的 CSS 問題,有簡單的問題示例,也有解決方法。 這個系列共有 58 個指南,70 個解決方案。

受影響的版本

IE6,IE7,IE8(譯者注:在IE9中切換瀏覽器版本為7、89均出現此bug,在IE11中切換瀏覽器版本均沒有出現該bug,這個…..僅供參考)

表現

排在第32個(及之后的)樣式會被忽略(例如<style>、<link>@import

教程日期

2009 8.12 14:58:58 星期三

描述

如果你正在維護一個網站,里面包含了很多第三方的廣告或應用程序,這些第三方的東西會依賴于他們自己的<style>(<link>)元素,本文中的bug就會令你抓狂…..我這里說的很多意思是32個。讓我們來看看下面的演示,然后我再解釋。

演示

由于該bug的天然特性,這個演示在一個單獨的頁面上:

HTML Code

  1. <style type="text/css"></style> <!--1--> 
  2. <style type="text/css"></style> <!--2--> 
  3. <style type="text/css"></style> <!--3--> 
  4. <style type="text/css"></style> <!--4--> 
  5. <style type="text/css"></style> <!--5--> 
  6. <style type="text/css"></style> <!--6--> 
  7. <style type="text/css"></style> <!--7--> 
  8. <style type="text/css"></style> <!--8--> 
  9. <style type="text/css"></style> <!--9--> 
  10. <style type="text/css"></style> <!--10--> 
  11. <style type="text/css"></style> <!--11--> 
  12. <style type="text/css"></style> <!--12--> 
  13. <style type="text/css"></style> <!--13--> 
  14. <style type="text/css"></style> <!--14--> 
  15. <style type="text/css"></style> <!--15--> 
  16. <style type="text/css"></style> <!--16--> 
  17. <style type="text/css"></style> <!--17--> 
  18. <style type="text/css"></style> <!--18--> 
  19. <style type="text/css"></style> <!--19--> 
  20. <style type="text/css"></style> <!--20--> 
  21. <style type="text/css"></style> <!--21--> 
  22. <style type="text/css"></style> <!--22--> 
  23. <style type="text/css"></style> <!--23--> 
  24. <style type="text/css"></style> <!--24--> 
  25. <style type="text/css"></style> <!--25--> 
  26. <style type="text/css"></style> <!--26--> 
  27. <style type="text/css"></style> <!--27--> 
  28. <style type="text/css"></style> <!--28--> 
  29. <style type="text/css"></style> <!--29--> 
  30. <style type="text/css"></style> <!--30--> 
  31. <style type="text/css"></style> <!--31--> 
  32. <style type="text/css">p { border: 5px solid #000; }</style> <!--32--> 
  33.   
  34. <p>I should have borders!</p> 

解決方案

以下是針對此bug的解決方案

方案(偽bug)

教程日期

2009 8.12 15:28:11 周三

修復版本

所有受影響的版本

描述

如果你在實際網站開發中遇到了這個問題,你也許不能選擇用“更少的樣式標簽”,解決方案可能會變得更復雜。基于那個事實,在修正的演示中,我會展示達到限制條件的情況:

由于該bug的天然特性,這個演示在一個單獨的頁面上:(譯者注:此處的頁面鏈接有錯誤,跟前一個演示鏈接是一樣的,明顯和下面的html代碼不符)

HTML 代碼:

  1. <style type="text/css">p { border: 5px solid #000; }</style> <!--1--> 
  2.   
  3. <p>I should have borders!</p> 

如果你不能采取“使用更少的樣式標簽”的解決辦法,問題就會變得更復雜。最好的方案就是采用一個后處理,將超量的樣式進行合并放入一個style里(如將多個<style>元素中的樣式放入一個<style>元素中)。

如果<style>元素中的內容是靜態的,你可以簡單地復制代碼并將它放在限制標簽前面的<link>/<style>元素中。

如果你已經火燒眉毛,需要一個快速修復方法的話,下面是我在the page where I found the bug找到的一段jQuery代碼,我沒有測試過這段代碼,所以使用者風險自負哦~代碼是這樣的:

  1. $(document).ready(function(){ 
  2.   // If msie and we have more than the allotted stylsheets... 
  3.   if ( $.browser.msie && $('style').length != document.styleSheets.length ) { 
  4.     var ssAry = $('style'); 
  5.     // Loop through the extra stylesheets not read and apply the styles found 
  6.     for ( var i = document.styleSheets.length; i < ssAry.length; i++ ) { 
  7.       var cssText = ssAry[ i ].innerHTML; 
  8.       // Replace newlines and then comments 
  9.       cssTextcssText = cssText.replace(/[\n\r]/g, ""); 
  10.       cssTextcssText = cssText.replace(/\/\*\**[^\*\/]*\*\//g, ""); 
  11.   
  12.       // Loop over all CSS selector groups... 
  13.       var regex = new RegExp(/{[^}]*}/); 
  14.       for ( var value = regex.exec( cssText ); value; value = regex.exec( cssText ) ) { 
  15.         // Split the css grouping into the selector and the CSS properties 
  16.         var pair = cssText.substring( 0, regex.lastIndex ) 
  17.                           .replace(/}/g, "").split(/{/); 
  18.         // Add it to the last DOM stylesheet 
  19.         document.styleSheets[ document.styleSheets.length - 1 ].addRule( 
  20.           pair[ 0 ].replace(/^\s+|\s+$/g, ""), 
  21.           pair[ 1 ].replace(/^\s+|\s+$/g, "") 
  22.         ); 
  23.         // Strip off the applied CSS 
  24.         cssTextcssText = cssText.substring( regex.lastIndex ); 
  25.       } 
  26.     } 
  27.   } 
  28. }); 

請注意,你不應使用這段代碼作為此問題的永久性修復方案。

原文鏈接:http://haslayout.net/css/32-Styles-Limitation

譯文鏈接:http://blog.jobbole.com/48353/

責任編輯:陳四芳 來源: 伯樂在線
相關推薦

2013-10-31 11:12:56

IECSS

2013-10-30 09:57:43

IECSS

2013-09-09 10:51:07

CSSIE瀏覽器

2013-10-31 10:59:23

IECSS

2013-10-29 15:20:38

IECSS

2013-10-29 10:32:59

IECSS

2010-08-19 14:19:12

IE6IE7IE8

2010-08-27 14:55:23

IE6IE7IE8

2009-08-13 10:12:07

IE的CSS Bug

2010-08-19 16:53:10

IE6IE7Firefox

2010-08-27 15:08:10

FirefoxIE6IE7

2010-08-17 15:38:49

CSS兼容IE7IE8

2010-09-03 09:55:10

CSS偽類hover

2010-08-20 11:24:44

IE7IE8CSS

2010-09-08 11:23:27

2010-12-21 14:59:10

CSS 3IE

2009-09-18 16:15:25

CSS樣式屬性

2017-07-20 11:11:39

前端CSS書寫規范

2010-08-19 09:02:06

2022-12-13 07:41:43

CSSCSS Houdi
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 成人午夜 | 欧美a级成人淫片免费看 | 国产精品久久国产精品 | 在线播放亚洲 | 亚洲一区二区三区在线免费观看 | 高清国产午夜精品久久久久久 | 欧美精品久久久久 | 四虎成人免费视频 | 97久久久| 亚洲毛片网站 | 亚洲成人精品久久 | 最新国产精品精品视频 | 国产精品成人一区二区三区 | 午夜在线观看视频 | 成人影视网址 | www.v888av.com| 国产1区2区| 涩涩操 | 四虎永久免费黄色影片 | 欧美456| 久久精品国产99国产精品 | 国产精品呻吟久久av凹凸 | 亚洲国产成人av好男人在线观看 | 欧美区在线观看 | 亚洲国产高清在线观看 | 亚洲欧美激情精品一区二区 | 亚洲视频一区在线 | 国产综合视频 | 中文字幕国产第一页 | 国产伦精品一区二区三毛 | 中文av在线播放 | 国产精品一区二区久久精品爱微奶 | 日韩另类视频 | 欧美另类视频 | 亚洲欧洲精品在线 | 国产一区二区视频免费在线观看 | 久久精品国产99国产精品 | 国产精品永久 | 秋霞电影一区二区 | 久久久99精品免费观看 | 亚洲免费精品一区 |