[Mobile Web] LEVEL 5 RESPONSIVE MEDIA -- Ex

MAX-WIDTH

 

Set the max-width of images to 100%.

img{
    max-width: 100%;
}

 

MAX-WIDTH ON ASSETS

 

Set the max-width of imagesembedsobjects, and videos to 100%.

img,
embed,
object,
video{
  max-width: 100%;
  }

 

MEDIA QUERY #1

 

Write a media query to target devices with a at least a 1.5 device-pixel-ratio, using the screen media type. Make sure to target the -webkit proprietary extension, as well.

@media 
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5){
  
  }

 

MEDIA QUERY #2

 

Assuming we have a 75px by 75px logo.png image and a high-resolutionlogo@2x.png image, include the high-resolution image within the media query you just wrote as a background-image on the .logo. Don't forget to set the background-size as well.

复制代码
@media
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
  .logo {
    background-image: url('logo@2x.png');
    -webkit-background-size: 75px 75px;
    background-size: 75px 75px;
  }
}
复制代码

 

PICTURE ELEMENT

 

Using the Scott Jehl PictureFill method, create a <picture> element with "Our Camp Site" as the alt text. Also add camp-site.jpeg as the smallest source size, with no @media qualifier.

<picture alt="Our Camp Site">
  <source src="camp-site.jpeg" />
</picture>

 

MEDIA SPECIFIC IMAGES

 

Now, add camp-site-lrg.jpeg as the second source, with an @media qualifier for devices with a width of at least 900px.

<picture alt="Our Camp Site">
  <source src="camp-site.jpeg" />
  <source src="camp-site-lrg.jpeg" media="(min-width:900px)"/>
</picture>

 

NOSCRIPT FALLBACK

 

Finally, add a <noscript> fallback block within the <picture> element to include a normal img tag, with the camp-site.jpeg and "Our Camp Site" alt text.

<picture alt="Our Camp Site">
  <source src="camp-site.jpeg" />
  <source src="camp-site-lrg.jpeg" media="(min-width: 900px)" />
  <noscript>
    <img src="camp-site.jpeg" alt="Our Camp Site" />
  </noscript>
</picture>

 

posted @   Zhentiw  阅读(305)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示