S
S
Sergey2017-03-09 12:25:06
Yii
Sergey, 2017-03-09 12:25:06

How to connect individual styles to a specific page in yii?

How to attach separate styles to a specific page that will be applied only to it? I just got acquainted with yii, unfortunately, I don't know php, because I'm doing layout.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-03-09
@Hando

Just like always. Or add styles to the head

//это во view
$this->registerCss('
body {background-color:#fff;}
');

or as a file.
//это во view
$this->registerCssFile('path/to/myfile');

If there are a lot of dependencies and they still need to be connected somewhere in the same set, then you can create an AssetBundle, more details here www.yiiframework.com/doc-2.0/guide-structure-asset...
As a rule, css is not connected in the view itself and js, since everything should be widgets when properly laid out, and widgets have their own method of connecting dependencies. And if there is a need to prescribe some css in the view, then most likely this is a global error in the structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question