0

How do I write the right adress, the code is:

.slide1 {  
    background: url(http://media.dunkedcdn.com/assets/prod/40946/580x0-9_cropped_1371566801_p17tbs0rrjqdt1u4dnk94fe4b63.jpg)no-repeat center;
}

How do I put a image from my resource file? I tried background-image: url("pic1.jpg") -that's the right address- and it doesn't work.

What I do is I put the images from a slideshow in css and put a simple cod afterwards in html to display it.

j08691
  • 204,283
  • 31
  • 260
  • 272
dan345
  • 1
  • 2
  • If you are pulling the image from a directory/folder that is outside of your .html file structure, then you have to specify the path to that (ex: url(images/pic1.jpg) – Mike Diglio Mar 16 '17 at 19:33

1 Answers1

0

You have to pass a width and a height in order to make it appear. Try it like this:

.slide1 {  
    background: url('http://media.dunkedcdn.com/assets/prod/40946/580x0-9_cropped_1371566801_p17tbs0rrjqdt1u4dnk94fe4b63.jpg') no-repeat center;
    width: 200px;
    height: 200px;
}

Edit: If the image is in the same directory where your css file is, simply use:

background: url('nameOftheFile.jpg') no-repeat center;

Also this thread may be interesting for you: How to go up a level in the src path of a URL in HTML?

Community
  • 1
  • 1
Reza Saadati
  • 1,224
  • 13
  • 27
  • I did this, as: .slider { max-width: 400px; height: 260px; margin: 20px auto; position: relative; – dan345 Mar 16 '17 at 19:35
  • my question is how do I write the path to a img file on my resource file, not like in the example I found, online image. Thanks! – dan345 Mar 16 '17 at 19:36
  • @danut is the image file in the same directory as your css? – Mike Diglio Mar 16 '17 at 19:37
  • No, it is in the "website" directory, where the index and all the other pages are, in HTML format. I used images from there on other page than index, and the others pics i use are in assets/img/.. – dan345 Mar 16 '17 at 19:40
  • I'll just put them there, thanks for the help, now I saw the edit. Thanks again! – dan345 Mar 16 '17 at 19:42
  • @danut you're welcome. Feel free to mark this answer as solved if it helped you. – Reza Saadati Mar 17 '17 at 17:12