简体   繁体   English

如何为移动体验制作响应式图像

[英]How to make Responsive Images for mobile experiences

UPDATE UPDATE


I have Fullscreen background image. 我有全屏背景图片。 This creates problems for mobile browsing for the images are large and hi-res. 这为移动浏览带来了问题,因为图像很大且高分辨率。

Next problem is with things like retina display how does a design/programmer prepare to deal with this issue? 接下来的问题是视网膜显示器如何设计/程序员如何准备处理这个问题? I see lot of article about how to switch between images. 我看到很多关于如何在图像之间切换的文章。 But then I get overly confused with pixel density vs resolution. 但后来我对像素密度与分辨率过分混淆。 The when and where it is needed and the how and why to target them. 需要的时间和地点以及如何以及为何将其作为目标。

Example: 例:

*Fullscreen background image at 1900x1080 resolution & 72dpi. *全屏背景图像,分辨率为1900x1080和72dpi。 For best optimization, How many images should there be per resolution/pixel density? 为了获得最佳优化,每个分辨率/像素密度应该有多少个图像? Furthermore, Given this scenario which library/plugin/symantics would be best on tackling this situation? 此外,鉴于这种情况,哪个库/插件/语义最适合解决这种情况?

Lastly, If i use media queries to target and switch background images will it download all the images? 最后,如果我使用媒体查询来定位和切换背景图像,它会下载所有图像吗? or just when the requirements have been met? 或者只是满足要求?

@media (min-device-width : 768px) 
and (max-device-width : 1024px) {
background-image:url('paper1024.png');
}

@media only screen 
and (min-width : 1824px) {
background-image:url('paper1900.png');
 } 

Thanks stack 谢谢堆栈


//old question didnt wnat to remove it for comment purposes// //旧问题并没有删除它以用于评论目的//

So I'm making a responsive website with fullscreen images. 所以我正在建立一个全屏图像的响应式网站。 The problem I've been running across is that the orginal images are far to large for mobile to download. 我一直在遇到的问题是原始图像对于移动下载而言要大得多。

Being new to responsive design, I had no idea that this was a problem and discouvered it on my own accord. 作为响应式设计的新手,我不知道这是一个问题,并且我自己也不予理睬。 I read a few article 我读了几篇文章

The best being: 最好的是:
http://www.alistapart.com/articles/responsive-images-and-web-standards-at-the-turning-point/ http://www.alistapart.com/articles/responsive-images-and-web-standards-at-the-turning-point/

My problem is that: I dont believe <picture> tag is open to the public? 我的问题是:我不相信<picture>标签对公众开放? I cant find any any more info on this. 我无法找到任何更多信息。

Does anyone know if this is allowed? 有谁知道这是否允许? Furthermore, more information/documentation on how to use it correctly. 此外,有关如何正确使用它的更多信息/文档。

If picture is non-applicable. 如果picture不适用。 Is there any " standard " persay on making images responsive with out bloating mobile bandwidth? 是否有任何“ 标准 ”的关注,使图像响应膨胀的移动带宽?

This is the way i did retinafying in my last project: 这是我在上一个项目中进行视网膜检查的方式:

First set images for desktop in an ordinary css using background-image: 首先使用background-image在普通css中设置桌面图像:

#bg {
  background: image-url('wallpaper_desktop.jpg') center top;
  background-size: 1024px 768px;
}

Then, I adress mobile phones eg iphone: 然后,我用iphone等手机:

@media only screen and (min-device-width: 320px) and (max-device-width: 480px){
  #bg {
    background: image-url('wallpaper_mobile.jpg') center top;
    background-size: 320px 480px;
  }
}

Then it comes to retina image handling. 然后它涉及视网膜图像处理。 Use an image, doubled in size (see the "@2x" in filename): 使用图像,大小加倍(请参阅文件名中的“@ 2x”):

@media only screen and (-webkit-min-device-pixel-ratio: 2) {
  #bg {
    background: image-url('wallpaper_mobile@2x.jpg') center top;
    background-size: 320px 480px; // Original size
  }
}

Since there are also iPads and MacBooks with Retina Displays, we should consider to serve them larger and hi res versions in comparison to hi res phones: 由于还有带Retina显示屏的iPad和MacBook,我们应该考虑为它们提供更大和高分辨率的版本,与高分辨率手机相比:

@media only screen and (max-device-width: 2048px) and (-webkit-min-device-pixel-ratio: 2) {
  background: image-url('wallpaper_desktop@2x.jpg') center top;
  background-size: 1024px 768px;
}

So, usually I'm using 4 versions per image. 所以,通常我每个图像使用4个版本。 2 desktop versions (one with doubled size for retina displays) and 2 mobile versions (also one with doubled size for retina displays) 2个桌面版本(一个用于视网膜显示屏的尺寸加倍)和2个移动版本(另一个用于视网膜显示屏的尺寸加倍)

By the way: There are no additional requests, when using media queries for additional images. 顺便说一句:当使用媒体查询附加图像时,没有其他请求。

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

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