Drupal克服IE 31样式表限制
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Drupal克服IE 31样式表限制相关的知识,希望对你有一定的参考价值。
To be placed in template.php preprocess_page function.\r\n\r\nBreaks stylesheets into 2 style tags with limit of 30 @imports each. IE has a limitation of 31 @imports or 31 style tags. (source: [http://john.albin.net/ie-css-limits/single-style-test.html](http://john.albin.net/ie-css-limits/single-style-test.html))
<?php // Consolidate all styles import into 1 style tag. Solves IE 31 style tag limit $styles_document = new DOMDocument(); $styles_document->loadHTML($vars['styles']); $style_elements = $styles_document->getElementsByTagName('style'); $stylesheets = ''; $stylesheets2 = ''; for ($i=0;$i<$style_elements->length;$i++) { $stylesheets .= $style_elements->item($i)->nodeValue . " "; if($i == 30) {break;} } $styles = '<style type="text/css" media="all">' . $stylesheets . "</style> "; for ($i=31;$i<$style_elements->length + 1;$i++) { $stylesheets2 .= $style_elements->item($i)->nodeValue . " "; if($i == 60) {break;} } if($stylesheets2 != '') { $styles .= '<style type="text/css" media="all">' . $stylesheets2 . '</style>'; } $vars['styles'] = $styles; ?>
以上是关于Drupal克服IE 31样式表限制的主要内容,如果未能解决你的问题,请参考以下文章
针对 IE 4096 选择器/样式表限制的 Rails 资产管道解决方案