jnf555 Posted February 3, 2011 Share Posted February 3, 2011 hi i am having problems with paths css file contaning body{background-image:url(' what path do i need here stars.jpg')} css folder images folder img stars.jpgcan anyone help pleasejnf555 Link to comment Share on other sites More sharing options...
dsonesuk Posted February 3, 2011 Share Posted February 3, 2011 body{background-image:url('css/images/stars.jpg');}would be my suggestion. Link to comment Share on other sites More sharing options...
jnf555 Posted February 4, 2011 Author Share Posted February 4, 2011 thanks for reply,but sorry still not workingjnf555 Link to comment Share on other sites More sharing options...
dsonesuk Posted February 4, 2011 Share Posted February 4, 2011 Right looking at this again, you have css file whatever.css in css folder, which contains body styling, YES!and a images folder INSIDE the css folder yes!, and within that 'images folder a stars.jpg' image, yes! then it should bebody{background-image:url('images/stars.jpg');}if the images folder with image inside, is outside the css folder, then it would bebody{background-image:url('../images/stars.jpg');}if the image is outside image folder, and can be seen along with, css folder and image folder, then it should be body{background-image:url('../stars.jpg');} Link to comment Share on other sites More sharing options...
jnf555 Posted February 4, 2011 Author Share Posted February 4, 2011 thanks for replyi have two folders in my site folderone css folder containing my css which has a body background has a imgand the other folder images has the img in itthanks for your help i will have a try with your advicejnf555 Link to comment Share on other sites More sharing options...
dsonesuk Posted February 4, 2011 Share Posted February 4, 2011 then it should be second optionbody{background-image:url('../images/stars.jpg');} Link to comment Share on other sites More sharing options...
jnf555 Posted February 4, 2011 Author Share Posted February 4, 2011 spot on works finebody{background-image:url('../images/stars.jpg');}can you please tell me if i have set my site up the hard wayi have a folder for my site, and then put other folders within it to house my css images etc, or is it best to let all the files live together in the main site folder thanks jnf555 Link to comment Share on other sites More sharing options...
thescientist Posted February 4, 2011 Share Posted February 4, 2011 no, setting them up this way will work, you just have to keep it mind when writing out your file paths. The only thing that might make it easier is to keep your stylesheet and html pages together, and then put all your images and scripts in subfolders. Then the paths in both the HTML and CSS will be the same. Link to comment Share on other sites More sharing options...
cousineaug Posted February 4, 2011 Share Posted February 4, 2011 Here is a good discussion of relative file pathsit explains visually the difference between"image/picture.gif""/image/picture.gif""../image/picture.gif"As for relative to the document and relative to the CSS, I find the best approach is to place the CSS at the top level. That way any relative file paths in the CSS are "down from root" Link to comment Share on other sites More sharing options...
dsonesuk Posted February 4, 2011 Share Posted February 4, 2011 What i generally do, is have images, that relate to design layout, logos, borders, headings, backgrounds etc within a image folder inside the css folder, images relating to page content are kept in a separate images folder.all you have to do, is get the correct link to the css file, if the image path is correct in relation to the css file it will work with no problem and show these images on the page. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.