Css url paths when moving it to a different folder

Hey. Its simple quation, but have litle problem with this.

Its my path for css - assets/content/stylsheets/my.css
Its path picture for background url - assets/images/picture.gif

I do the following in my.css background: transparent
url(…/…/images/picture.gif).

but the path is not correct, the image is not found. I tried with one
…/ and easy images/picture.gif. Not work. When i add picture in folder
with css and add path - background: transparent url(picture.gif) all in
fine.

Dmitrij B. wrote in post #1100975:

Hey. Its simple quation, but have litle problem with this.

Its my path for css - assets/content/stylsheets/my.css
Its path picture for background url - assets/images/picture.gif

I do the following in my.css background: transparent
url(…/…/images/picture.gif).

but the path is not correct, the image is not found. I tried with one
…/ and easy images/picture.gif. Not work. When i add picture in folder
with css and add path - background: transparent url(picture.gif) all in
fine.

I find that the easiest way to figure out these relative paths is to
look at the paths generated in the HTML in the browser. Once you know
the exact path to your assets as seen by the browser it should be pretty
easy to deduce the relative path from one asset to another.

Here’s a quick example:

Demo

CSS

#div_with_back_image {
background-image: url(‘rails.png’);
height: 100px;
}

This is working for me in development mode at least.

Robert W. wrote in post #1101143:

I find that the easiest way to figure out these relative paths is to
look at the paths generated in the HTML in the browser. Once you know
the exact path to your assets as seen by the browser it should be pretty
easy to deduce the relative path from one asset to another.

Sorry, disregard my last reply!

This is the proper way:

.class { background-image: url(<%= asset_path ‘image.png’ %>) }

Taken from: