Ramesh Pareek
Ramesh Pareek

Reputation: 1669

css font url stops working when publishing Assets in yii2

In my css file

 @font-face {
             url('fontpu/anmo000-webfont.woff') format('woff'),
             url('fontpu/anmo000-webfont.ttf') format('truetype'),
                            }

    .punjabi{

    font-family: 'anmollipiregular';
    }

then I registered this in my AppAsset class.

public $css = [
        'css/site.css',
        'css/punjabi.css',
    ];

the fontpu folder is in the web folder (the web accessible folder which contains index.php).

if I place the css under the <style> tags in the index.php the font works fine but when publishing asset, it does not load. How do I give font's path to it?

Upvotes: 0

Views: 432

Answers (1)

soju
soju

Reputation: 25312

According to W3 :

Partial URLs are interpreted relative to the source of the style sheet, not relative to the document

You should simply use the correct relative path :

url('../fontpu/anmo000-webfont.woff') format('woff'),
url('../fontpu/anmo000-webfont.ttf') format('truetype'),

Upvotes: 2

Related Questions