Relative paths in CSS are relative to the stylesheet file. So if you have this structure:
- style.css
- images/
-- logo.png
-- background.jpg
Then the paths in CSS for the images would be url(images/logo.png)
and url(images/background.jpg)
. This is because the relative paths in CSS are relative to the stylesheet itself, not the main domain (if you want that, start with a slash: url(/images/logo.png)
).
None of this is affected by how you choose to enqueue the file.
Where you might be going wrong is that you mentioned a parent theme. If you’re trying to load an image from the parent theme, a relative path like the above example isn’t going to work. CSS has no knowledge or concept of a parent/child theme relationship.
So if your directory structure looks like this:
- parent-theme/
-- images/
--- logo.png
- child-theme/
-- style.css
-- images/
--- background.jpg
So if you want to go up a directory and then into the parent directory your path needs to look be url(../parent-theme/images/logo.png)
.