Css
第一方式(不常用)
$cssString = "body *{
-webkit-filter: grayscale(100%); /* webkit */
-moz-filter: grayscale(100%); /*firefox*/
-ms-filter: grayscale(100%); /*ie9*/
-o-filter: grayscale(100%); /*opera*/
filter: grayscale(100%);
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
filter:gray; /*ie9- */
}";
$this->registerCss($cssString);
确定,可读性不好
第二种方式,自己用的比较多,推荐
新建CssBlock.php
use yii\widgets\Block ;
class CssBlock extends Block{
/**
* @var null
*/
public $key = null;
/**
* @var int
*/
public $options = [];
/**
* Ends recording a block.
* This method stops output buffering and saves the rendering result as a named block in the view.
*/
public function run()
{
$block = ob_get_clean();
if ($this->renderInPlace) {
throw new \Exception