【问题标题】:Is there any way to have an image on an html page default to another image if the original source isn't there? [duplicate]如果原始来源不存在,有没有办法让 html 页面上的图像默认为另一个图像? [复制]
【发布时间】:2012-04-26 16:42:24
【问题描述】:

我有一个包含人物图片的网站。有时,包含所有图像的服务器出现故障,我的网站显示损坏的图像链接。我想看看网页上是否有以下逻辑,您可以在其中 src 一张图片,但如果加载不正确,则默认为另一张图片作为备份?

如果需要js或jquery等我很好。 .

【问题讨论】:

标签: jquery html asp.net-mvc image


【解决方案1】:

我认为你可以用 css 做到这一点。只需在图像类上做这样的事情。并将其设置为html标签

.myimage{
    background: url("images/default.png");

}

或查看this

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2021-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多