Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS背景图像的渲染_Css_Xhtml - Fatal编程技术网

CSS背景图像的渲染

CSS背景图像的渲染,css,xhtml,Css,Xhtml,我在服务器文件夹中有一个映像(C:\resources\image\client-a.jpg)。是否可以以这样的方式渲染背景图像:如果client-a.jpg可用,则以其他方式渲染它render client-default.png <style type="text/css"> #divElement { position: absolute; top: 50%; left: 50%; margin-t

我在服务器文件夹中有一个映像(C:\resources\image\client-a.jpg)。是否可以以这样的方式渲染背景图像:如果client-a.jpg可用,则以其他方式渲染它render client-default.png

    <style type="text/css">
    #divElement {
        position: absolute;
        top: 50%;
        left: 50%;
        margin-top: -200px;
        margin-left: -400px;
        background-image: url(/TestWeb/theme/client-default.png);
        width: 800px;
        height: 400px;
    }
</style>

#分割元素{
位置:绝对位置;
最高:50%;
左:50%;
利润上限:-200px;
左边距:-400px;
背景图像:url(/TestWeb/theme/client default.png);
宽度:800px;
高度:400px;
}

您可以使用多个图像,前提是它们不是透明的

background-image: url(/image/client-a.jpg),url(/image/client-default.png);

因此,当第一个不可用时,将显示第二个。

将来,我可能会有client-b.jpg、client-c.jpg等。。。这可能对我不起作用。我认为将图像保留在上下文根之外更好。上下文指的是其他网络位置,对吗?您可以这样做
背景图像:url(http://full/client-a/address.jpg),网址(http://full/client-b/address.jpg),url(/TestWeb/theme/client default.png)不,我的意思是服务器位置C:\resources\image\client-a.jpg
url(C:\resources\image\client-a.jpg)
可能会起作用,但只能在您的服务器上运行。。你必须把你的图片放在某个地方,或者放在某种Web服务器上,所以url以
http:..
开头,而不是
c:..