2017-08-09 133 views
1

当使用background-image我注意到,它不会与图片来自一个方向的网页链接的工作,像这样:背景图像URL

body { 
background-image: url("http://www.example.comenter/2312.jpg"); 
} 

但如果我直接从一个文件夹目录链接它,它工作得像这样的好:

body { 
background-image: url("C://Users/Jane/Desktop/2312.jpg"); 
} 

为什么它不适用于url链接?

+1

由于没有什么'HTTP:// www.example.comenter/2312.jpg',这是行不通的。 – Ofisora

回答

3

它正常工作与一个URL链接:

body { 
 
background-image: url("http://via.placeholder.com/400x200"); 
 
}

0

其实它的工作原理,但你应该检查,如果该链接是可用的。

0

你可以使用这样的:

body{ 
    background: url('http://www.example.comenter/2312.jpg'); 
} 

如果它不工作下面的链接没有任何图像,尝试使用其他图片。

0

background-image属性指定要用作元素背景的图像。

只需检查您在url中指定的链接可能是该路径不包含任何图像或请检查您想要在网页中显示的图像路径。

body { 
 
    background-image: url('http://www.publicdomainpictures.net/pictures/130000/velka/pink-simple-background.jpg'); 
 
}
<html> 
 

 
<head> 
 
</head> 
 

 
<body> 
 
    <h1 style="color:white">Hello World</h1> 
 
</body> 
 

 
</html>