default.ctp中的CakePHP 2 IE条件CSS

default.ctp中的CakePHP 2 IE条件CSS,php,css,internet-explorer,cakephp,Php,Css,Internet Explorer,Cakephp,我正在使用CakePHP 2开发一个应用程序,在default.ctp模板文件中遇到了一个问题。我在网上搜寻过,找不到适合我的答案。我找不到一种方法来为IE包含条件CSS文件 我正在为我的普通CSS做以下工作 echo $this->Html->css(array('screen', 'print')); echo $this->fetch('css'); 这可以很好地工作,并生成以下html <link rel="stylesheet" type="text/css

我正在使用CakePHP 2开发一个应用程序,在default.ctp模板文件中遇到了一个问题。我在网上搜寻过,找不到适合我的答案。我找不到一种方法来为IE包含条件CSS文件

我正在为我的普通CSS做以下工作

echo $this->Html->css(array('screen', 'print'));

echo $this->fetch('css');
这可以很好地工作,并生成以下html

<link rel="stylesheet" type="text/css" href="/css/screen.css" />
<link rel="stylesheet" type="text/css" href="/css/print.css" /> 

我需要能够添加到上述CSS中的是以下条件include

<!--[if IE]> <link rel="stylesheet" type="/text/css" href="/css/ie.css" /> <![endif]-->

在获取之前,我看不出如何将ie.css包含到css文件数组中

如果能为解决这个问题提供帮助,我将不胜感激

问候


rickl

您可以使用条件CSS Includes

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>
将以下内容添加到布局中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

将以下内容添加到视图中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

资料来源:


在IE11和FF中测试→ 适合我。

您可以使用条件CSS包含:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>
将以下内容添加到布局中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

将以下内容添加到视图中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

资料来源:


在IE11和FF中测试→ 适合我。

您可以使用条件CSS包含:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>
将以下内容添加到布局中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

将以下内容添加到视图中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

资料来源:


在IE11和FF中测试→ 适合我。

您可以使用条件CSS包含:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>
将以下内容添加到布局中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

将以下内容添加到视图中:

<?php if ($ieCond = $this->fetch('ie')): ?>
<!--[if IE]><?php echo $ieCond; ?><![endif]-->
<?php endif; ?>
<?php $this->Html->css('ie', array('block' => 'ie')); ?>

资料来源:


在IE11和FF中测试→ 适合我。

只需在IE条件块之间添加css即可

<!--[if IE]>
<?php $this->Html->css(array('ie'); ?>
<![endif]-->

只需在IE条件块之间添加css即可

<!--[if IE]>
<?php $this->Html->css(array('ie'); ?>
<![endif]-->

只需在IE条件块之间添加css即可

<!--[if IE]>
<?php $this->Html->css(array('ie'); ?>
<![endif]-->

只需在IE条件块之间添加css即可

<!--[if IE]>
<?php $this->Html->css(array('ie'); ?>
<![endif]-->