Yii2 how to include multiple css files from specific view or controller action

Tags: javascript,css,frameworks,yii2-advanced-app,yii2-user

Problem :

I have installed YII2 of my local server and I want to include separate css file from specific view or controller action, I have used a method but the method on include one css file in my specific view , could any one answer me for the solution my code is below. The firs file is include and the remaining is ignored.

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/iCheck/flat/blue.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], 'css-screen-theme');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/morris/morris.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], 'css-screen-theme');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/jvectormap/jquery-jvectormap-1.2.2.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], 'css-screen-theme');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/datepicker/datepicker3.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], 'css-screen-theme');

Solution :

Just remove one parameter from the above code , the remaining code is correct.I am sending an example for modified code.

this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/iCheck/flat/blue.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], '');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/morris/morris.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], '');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/jvectormap/jquery-jvectormap-1.2.2.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], '');

$this->registerCssFile(Yii::$app->request->BaseUrl."/assets/plugins/datepicker/datepicker3.css", [ 'depends' => [BootstrapAsset::className()], 'media' => 'screen', ], ''); Now all the css files will be shown now.

    CSS Howto..

    How to use css method of rotation in jquery

    How to apply CSS to document.write()?

    how to combine widget webapp framework with SEO-friendly CSS and JS files

    How to get rid of white space between css horizontal list items? [duplicate]

    How can I apply a vertical scrollbar to a div with a percentage height?

    how to override unselectable=“on” with css in IE10?

    How to style a table-like div with css? How to fill a “column”?

    HTML/CSS: How to resize checkboxes (without overlapping)

    How do I access HTML elements created by a function? The elements are “undefined” and therefore not CSS apply-able

    How to assign a Css class on an item based on click

    how to make the img at the left side and the texts at the right side vertically line up

    How to revert back to Desktop website from Mobile Website when using CSS Media Queries?

    How can I override an inline style with an external css?

    How to set table column widths to the longest value, excluding header

    How can I increase space just above the footer line?

    How do I bottom-align bars in a CSS vertical bar chart?

    How to make Online iPhone “Card Game” with HTML5 [closed]

    How long can a CSS selector be?

    How to create an animated rainbow line using CSS or Javascript?

    How to align to the center a div with position absolute within a div with position relative?

    How to overlap a CSS background over an tag?

    How to get to be the same width as

    how to make colors generated via Javascript be stored permanently in CSS file with or without use of PHP

    How to make angular material dialog box work in IE10

    How to select by CSS styles in jQuery?

    How to get @media to take precedence over normal styling

    How do I get the slide in as you scroll down (CSS Trick) technique to work in Safari?

    How to customise button ( CSS, HTML)

    How do you get this result, using Jquery Scroll Event & offset/position, css or javascript?

    Show / Hide HTML using swatch / HTML 5 - dynamic HTML