如何以HTML显示Webp图像格式(浏览器) [英] how show webp image format in HTML (browsers)

查看:2372
本文介绍了如何以HTML显示Webp图像格式(浏览器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是图像的新格式,但是我不知道如何以HTML格式显示. 有人知道我该怎么做吗?除chrome之外,哪个浏览器可以显示此图像格式? 示例图片

I know this is a new format for images but I don't know how to show it in HTML. Does anyone know how I can do that? Which browser can show this image format except chrome? sample image

更新:新版本的浏览器可以支持这种格式.

Update: new version of browsers can support this format.

推荐答案

您可以像使用任何图像一样使用webp:

You use webp like any image:

<img src="img.webp" />

但是,由于并非始终受支持(请参见 http://caniuse.com/#feat=webp),您可以使用它来设置后备广告:

However since it's not always supported (see http://caniuse.com/#feat=webp), you can use this to set a fallback:

<picture>
  <source srcset="img.webp" type="image/webp">
  <source srcset="img.jpg" type="image/jpeg"> 
  <img src="img.jpg">
</picture>

这篇关于如何以HTML显示Webp图像格式(浏览器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆