【问题标题】:How to use BBC's Imager.Js for responsive images in C# MVC如何在 C# MVC 中使用 BBC 的 Imager.Js 获取响应式图像
【发布时间】:2016-01-21 07:03:45
【问题描述】:

我想使用 BBC Imager.Js 库根据设备窗口大小在我的网站上加载响应式图像。我已经在服务器上存储了不同大小的图像。

我在 github 上关注了 BBC-News/Imager.js/ 的文档,但由于缺乏知识,我无法让它工作。请帮助我如何完成这项任务,或者有没有更好的技术来完成这项工作。

【问题讨论】:

    标签: javascript c# css image


    【解决方案1】:

    我解决了我的问题。我打算使用这是一项古老的技术,现在使用 <Picture> 标签根据我们图像目录中的浏览器大小自动选择图像。

    <picture> <source media="(min-width: 1024px)" srcset="www.example.com/image-large.jpg, www.example.com/image-large.jpg 2x"> <source media="(min-width: 768px)" srcset="www.example.com/image-medium.jpg, www.example.com/image-medium.jpg 2x"> <source media="(min-width: 480px)" srcset="www.example.com/image-mobile.jpg, www.example.com/image-mobile.jpg 2x"> <source srcset="www.example.com/image-small.jpg, www.example.com/image-small.jpg 2x"> <img src="www.example.com/image-mobile.jpg" alt="@item.Title"> </picture>

    此图片标签中的图片标签是为旧版浏览器支持的,希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-03
      • 2015-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-22
      相关资源
      最近更新 更多