1

Just started building a website and its my first time using MAMP and CodeIgniter Framework. I am trying to get images from the CSS code to display but they are not showing up when I open the website in the localhost. My question is:

Do I need to put the images in a specific location in MAMP's docs? or is there something I am not configuring first?...(I bet its something tiny I have not done..) Just to note I have tried changing the URL and file location a few times but had no luck..

Here is the CSS code which links to the image I am trying to display, everything else works except the images are not displaying.

Please help.

#header {
overflow: hidden;
width: 1000px;
height: 50px;
margin: 00px auto 20px auto;
background: url(/Applications/MAMP/htdocs/website/application/views/images/img03.jpg) no-repeat right top;
}
Daveloper87
  • 706
  • 1
  • 8
  • 13
  • 3
    Try changing `/Applications/MAMP/htdocs/website/application/views/images/img03.jpg` to `/application/views/images/img03.jpg` – j08691 Mar 11 '13 at 19:45
  • thanks for the reply, I tried this and changing URL's a few times but still no luck :( – Daveloper87 Mar 11 '13 at 19:51

2 Answers2

4
background: url(/Applications/MAMP/htdocs/website/application/views/images/img03.jpg)

"localhost" points to htdocs, you must set starting the route from there

background: url(/website/application/views/images/img03.jpg)

can use with F12 if you use chrome if the correct path to the image

  • Thanks for your help, I tried this as well but no luck..I forgot to mention I was using CodeIgniter in the question so I don't know if that helps answer a few questions?.. – Daveloper87 Mar 11 '13 at 20:05
  • CSS, JAVASCRIPT, IMAGES, ETC is allowed to be accessed directly, maybe you should create a directory "static" for these files in root of your directory – John Paul Cárdenas Mar 11 '13 at 20:15
  • Fixed it! Needed to create a folder in the main website folder rather than under application. Thanks for your help! – Daveloper87 Mar 11 '13 at 20:26
1

Change your images path. For example, if you have your css file in a folder called css, your images are in views and the 2 folders are on the same level:

background: url(../views/images/img03.jpg) no-repeat right top;
Zoltan Toth
  • 46,981
  • 12
  • 120
  • 134
  • thanks for the reply, I tried this and changing URL's a few times but still no luck – Daveloper87 Mar 11 '13 at 19:52
  • you have to show your folder structure.. your paths are the issue without doubts – Zoltan Toth Mar 11 '13 at 19:58
  • Probably would of helped if I actually informed everyone what Framework I am using :s ...I am using CodeIgniter so its under their file structure if that helps? – Daveloper87 Mar 11 '13 at 20:04
  • nope, it still doesn't tell where is your CSS. Can you provide the path, like you did for the image - `/Applications/MAMP/htdocs/website/application/views/images/img03.jpg`? – Zoltan Toth Mar 11 '13 at 20:15
  • The CSS is in a folder css inside the views folder and that displays fine – Daveloper87 Mar 11 '13 at 20:19
  • Would it make a difference to place the CSS in with the HTML and save that as the .PHP file? – Daveloper87 Mar 11 '13 at 20:23
  • Fixed it! Needed to create a folder in the main website folder (website/assets) and put the images in there, rather than under application/views/images. Thanks for your help! – Daveloper87 Mar 11 '13 at 20:27