Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking CSS to images in a subfolder

I cant figure out the right path to use in my CSS file for

    html { background-image: url('backgroundImage.jpg'); }

My folder structure is as follows:

..\MySite\ <!-- HTML files here -->

..\MySite\css\

..\MySite\js\

..\MySite\images\ <!-- backgroundImage.jpg here -->

like image 453
James Forbes Avatar asked Mar 27 '26 05:03

James Forbes


2 Answers

 html{ background-image: url('../images/backgroundImage.jpg'); }

../ is telling your CSS file to go one directory back and search for the image from that folder (in this case your root folder)

like image 149
Slavenko Miljic Avatar answered Mar 29 '26 21:03

Slavenko Miljic


use html{ background-image: url('/images/backgroundImage.jpg'); }

starting with / means you start at the root of your site

like image 35
daniel Avatar answered Mar 29 '26 21:03

daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!