Reference images in css


#1

My images are located in www/images, i am able to refer them in html using

<img src="images/nice-one.png"/>

, but when i refer them in css, it tries to use the relative path from css file location rather than base dir like what the html does

image background

<body>
some text here
</body>

CSS in file css/application.css

body {
      background-image: 'images/nice-one.png';
    }

CSS breaks since, ionic looks for images under css/images//nice-one.png

how can i refer to images consistently rather using relative paths in css files ?.


#2

To change this we would need to be able to change the browser :smile:

Angular doesn’t change the way the browser handles CSS, only HTML and JS

So you will have to use relative paths for images in you css