djlfreak Posted May 20, 2010 Share Posted May 20, 2010 I'm new to PHP so I'm probably missing something simple but I can't figure it out. I need this urgently so I hope someone can help. The problem is when I browse my php pages, the css background images don't show up. The images in the body of the page show up fine, it's just the css background images. The images that aren't showing are in the header and footer which are in include files. Does php recognise images in a CSS file, what do I need to do to fix this. Please help :'( Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/ Share on other sites More sharing options...
premiso Posted May 20, 2010 Share Posted May 20, 2010 PHP has nothing to do with the CSS / images unless a php script is serving either or. WIthout any code hard to help, but you probably wanted the CSS Section / Client Side section. Of course, unless PHP is actually dishing out / processing images or the css files. Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061219 Share on other sites More sharing options...
-Karl- Posted May 20, 2010 Share Posted May 20, 2010 Are the images in the correct directory? Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061221 Share on other sites More sharing options...
djlfreak Posted May 20, 2010 Author Share Posted May 20, 2010 My file structure is: Folders Files CSS - screen.css Includes - layout1.php Images - has images index.php -the page where images aren't showing The attached files might make things clearer. The css file won't attach but it's straightforward eg: #header { clear:both; float:left; width:100%; height:175px; border-bottom: 1px solid #000000; background-image: url(images/dvdfflogo4.jpg); background-repeat:no-repeat; background-position: center; background-color:black; text-align: right; } Thanks for replying. Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061225 Share on other sites More sharing options...
-Karl- Posted May 20, 2010 Share Posted May 20, 2010 background-image: url(Images/dvdfflogo4.jpg); You state your directory is "Images" (capital I). Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061227 Share on other sites More sharing options...
djlfreak Posted May 20, 2010 Author Share Posted May 20, 2010 No Karl, the images folder has a lowercase i, anything else I could be missing? Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061230 Share on other sites More sharing options...
-Karl- Posted May 20, 2010 Share Posted May 20, 2010 Well, since you're css file is in a CSS folder. background-image: url(./images/dvdfflogo4.jpg); Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061231 Share on other sites More sharing options...
premiso Posted May 20, 2010 Share Posted May 20, 2010 No Karl, the images folder has a lowercase i, anything else I could be missing? It is not "suggested" but for testing purposes, try the absolute path to the image to see if that works. If it does, then it is a path issue. Absolute path being http://www.yoursite.com/images/image.jpg. It is not suggested for CSS stuff for the reason that if you change domain names etc, you have to manually fix this. If the absolute path works, try a variation of relative paths, as Karl suggested, but ../ may work as well etc. See if that fixes the issue. If, however, the absolute path does not work, something else is going on and the images are not where you are expecting them to be. Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061234 Share on other sites More sharing options...
djlfreak Posted May 20, 2010 Author Share Posted May 20, 2010 No that didn't work either. It's so strange I just can't see the problem. Thank you so much for trying to help. PHP is so hard. I have GD support enabled and when I view the file as a html it works fine so I thought it must have something to do with PHP and images in css. It's probably something obvious that I just can't see but it's definately a PHP problem or it wouldn't work as a html file. Debbie:shrug: Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061235 Share on other sites More sharing options...
-Karl- Posted May 20, 2010 Share Posted May 20, 2010 Well, if you post some code we could help further. Have you also tried ../images? Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061236 Share on other sites More sharing options...
djlfreak Posted May 20, 2010 Author Share Posted May 20, 2010 ../ worked. You guys are genuises, thank you so much, I would never have figured that out on my own. I'm doing my final project for a PHP course and this forum is just brillant. I'm sure I'll be back again. Kind Regards, Debbie Quote Link to comment https://forums.phpfreaks.com/topic/202405-css-background-images-not-showing-on-php-pages/#findComment-1061238 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.