Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
CSS
.ws-bg:nth-child(2) { 
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/onepgscr-5.jpg); 
}


i cannot change the online image to local image with this code url("images/image.png");

please help me solve this thank you

What I have tried:

CSS
.ws-bg:nth-child(2) { 
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/onepgscr-5.jpg); 
}


i cannot change the online image to local image with this code
CSS
url("images/image.png");


please help me solve this thank you
Posted
Updated 29-Apr-16 23:39pm
v2
Comments
Sergey Alexandrovich Kryukov 30-Apr-16 1:55am    
Most likely, this is because you don't know how path names work. "images/image.png" is relative to the file using it.
Is that what you mean to do?
What is the location of "image.png" relative to "https://s3-us-west-2.amazonaws.com"?
And, by the way, think of the way you ask questions? Isn't that obvious that you don't show important detail?
—SA

As Sergey point out, the relative location of the image is important.
See Quick Reminder About File Paths | CSS-Tricks[^]

Another way is to use the absolute path, but that will sooner or later get you into trouble.
But if you want to do a test you can use the following syntax:
C#
url('file:///<full path="">')</full>

Example :
C#
url('file:///C:/Temp/MyImage.png')
 
Share this answer
 
Probably some error with the Path, Check this similar post for CSS Image path References.


Just try this to find the issue,

Create a Folder called Test in your Desktop or some directory

Inside the Test Folder, Create another folder called Images and save the online image from the above url as "image.png"

Create an html file (test.html) inside the Test Folder,with the following content and save it, Later try to open the file in Web Browser. you could able to see the Image loaded from Local.

HTML
<html>
<head>    <style>
        body {
            background-image: url(Images/image.png);
        } </style>

    
</head>
<body>    
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900