简体   繁体   English

渲染CSS背景图像

[英]Rendering CSS background-image

I have an image on server folder (C:\\resources\\image\\client-a.jpg). 我在服务器文件夹上有一个图像(C:\\ resources \\ image \\ client-a.jpg)。 Is it possible to render the background-image in such a way that if client-a.jpg is available, then render it else render client-default.png? 是否可以通过以下方式渲染背景图像:如果有client-a.jpg可用,则进行渲染,否则渲染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>

You can use multiple images provided they are not transpareny like this 您可以使用多张图片,只要它们不是透明的

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

So when the first is not available the second will be displayed. 因此,当第一个不可用时,将显示第二个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM