Yii框架2.0添加介质打印到CSS链接 [英] Yii framework 2.0 add media print to css link

查看:144
本文介绍了Yii框架2.0添加介质打印到CSS链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与Yii框架2.0工作我包括下面里面的的code一个CSS文件的资产/ AppAsset.php

Working with Yii framework 2.0 I include a css file with the code below inside assets/AppAsset.php.

public $css = [
    'css/style.css',
];

当我在网页浏览器我看到头标记以下code检查元素:

When I inspect element on the web browser I see the following code in the header tag:

<link href="/locahost/mywebsite/css/style.css" rel="stylesheet">

我想补充在 print.css 以网页是 媒体=打印 。我怎么能添加属性的媒体=打印到Yii框架2.0中的CSS链接?

I would like to add the print.css to the web page with media='print'. How could I add the attribute media='print' into the css link within Yii framework 2.0?

推荐答案

有一个的 cssOptions 为Assetsbundle,在那里你可以定义媒体属性,但它会添加所有该资产注册你的CSS文件。

There is a cssOptions attribute for the Assetsbundle, where you can define the media, but it will add all of your css file registered in that asset.

如果您想单独使用它,你需要创建一个新的资产为。

If you want to use it separately, you need to create a new asset for that.

在下面你的URL可以找到,如何让自定义资产以及如何将其注册到您的应用程序(布局):

Within the URL below you can find, how to make a custom asset and how to register it to your app (layout):

http://www.ramirezcobos.com/2013/12/28/adding-fontawesome-to-your-yii2-project-via-composer/

这篇关于Yii框架2.0添加介质打印到CSS链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆