[英]How to use webp image format in HTML
I know this is a new format for images, but I don't know how to show it in HTML.我知道这是一种新的图像格式,但我不知道如何在 HTML 中显示它。
Does anyone know how I can do that?有谁知道我该怎么做? Which browsers can show this image format besides chrome?
除了 chrome,还有哪些浏览器可以显示这种图片格式?
You use webp like any image:您可以像使用任何图像一样使用 webp:
<img src="img.webp" />
However since it's not always supported (see http://caniuse.com/#feat=webp ), you can use this to set a fallback:但是,由于它并不总是受支持(请参阅http://caniuse.com/#feat=webp ),您可以使用它来设置回退:
<picture>
<source srcset="img.webp" type="image/webp">
<source srcset="img.jpg" type="image/jpeg">
<img src="img.jpg">
</picture>
如果找不到指定路径的图像怎么办,在这种情况下如何显示无图片图像,类似于以下内容:
<img src="img.jpg" onerror="this.src = 'nopicture.gif';"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.