Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-principles/use-a-retina-image-for-higher-resolution-displays.md
Oliver Eyton-Williams dec409a4bd fix: s/localeTitle/title/g
2020-10-06 23:10:08 +05:30

2.0 KiB
Raw Blame History

id, challengeType, videoUrl, forumTopicId, title
id challengeType videoUrl forumTopicId title
587d78b1367417b2b2512b0a 0 https://scrimba.com/c/cPp7VfD 1 针对高分辨率屏幕应使用视网膜图片

Description

随着联网设备的增加设备的尺寸和规格有所不同它们使用的显示器在内部和外部可能也不同。像素密度PPI 或 DPI就是设备之间的其中一个不同点。最著名的显示器就是最新的 Apple MacBook Pro 笔记本电脑和最近的 iMac 电脑上的“视网膜显示器”。由于“视网膜”和“非视网膜”显示器之间的像素密度不同,某些未考虑高分辨率显示器的图像在高分辨率显示器上渲染时可能看起来“像素化”。

使图像在高分辨率显示器(例如 MacBook Pro 的“视网膜显示器”)上正常显示的最简单方法是将其 width 和 height 值设置为原始文件的一半,如下所示:

<style>
  img { height: 250px; width: 250px; }
</style>
<img src="coolPic500x500" alt="A most excellent picture">

Instructions

设置 img 标签的 widthheight 为它们原始宽高的一半。在这个例子中,原始 height 和原始 width 的值都为 200px。

Tests

tests:
  - text: '<code>img</code> 标签的 <code>width</code> 值应为 100px。'
    testString: assert($('img').css('width') == '100px');
  - text: '<code>img</code> 标签的 <code>height</code> 值应为 100px。'
    testString: assert($('img').css('height') == '100px');

Challenge Seed

<style>
  
</style>

<img src="https://s3.amazonaws.com/freecodecamp/FCCStickers-CamperBot200x200.jpg" alt="freeCodeCamp sticker that says 'Because CamperBot Cares'">

Solution

// solution required