如何使用cakePHP在css中添加media ='screen'?

时间:2015-11-24 11:49:57

标签: css cakephp

<?php
    echo $this->Html->css(
        array(
            '/printPlugin/css/960',
            '/printPlugin/css/screen',
            '/printPlugin/css/print',
            '/printPlugin/src/css/print-preview'
          )
        );
?>

此代码生成以下HTML:

<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/960.css" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/screen.css" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/print.css" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/src/css/print-preview.css" />

我的预期输出是:

<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/960.css"  media="screen"/>
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/screen.css" media="screen"  />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/src/css/print-preview.css" media="screen"/>

这意味着我想在每个CSS链接中添加media="screen"

N.B:我正在使用cakePHP 3

1 个答案:

答案 0 :(得分:10)

您可以在这里使用

<?php echo $this->Html->css(['mycss'],['media' => 'print']); ?>

输出会像这个html

<link rel="stylesheet" href="/myproject/css/mycss.css" media="print"/>