1

I'm trying to connect my CSS file into my project. For this I do:

In /web/css/ I've created my-custom.css file. Later in /views/my_folder/_form.php I've added these lines:

use \app\assets\AppAsset;
AppAsset::register($this);

but it still does not work. I'm new in Yii2, so maybe I do something wrong. Any suggestions what I need to do else?

1 Answer 1

2

This might be helful to you

1) Open Frontend folder

2) In that open assets Folder

3)Open Appasset.php

then write

public $css = [
        'css/my-custom.css'
    ];

Or else Try this in your view file

$this->registerCssFile("http://example.com/css/my-custom.css", [
    'depends' => [BootstrapAsset::className()]       
]);
Sign up to request clarification or add additional context in comments.

3 Comments

have you checked base path ? Is it like public $basePath = '@webroot'; public $baseUrl = '@web'; In appasset.php
yes, public $basePath = '@webroot'; public $baseUrl = '@web';
Is it Worked for you??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.