[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 images
, embeds
, objects
, 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>
相关文章
- IntelliJ IDEA创建maven web项目(IDEA新手适用)
- Web Service进阶(一)运行原理[通俗易懂]
- web安全色_WEB标准颜色
- WEB开发--html 01html介绍
- WEB前端学习--补3月30号课堂笔记
- Java Web的web.xml文件作用及基本配置详解编程语言
- 器步步俱升:手把手教你配置Linux Web服务器(linux配置web服务)
- MySQL与jQuery技术:开发交互式Web应用(mysqljquery)
- 服务器极速搭建Linux Web 服务器,让你享受极速体验!(linux搭建web)
- 与web技术基于MySQL Redis与Web技术的一体化应用(mysqlredis)
- 展示Web与Oracle的极致结合(web oracle)
- Apache与MySQL联动改变Web服务(apache跟mysql)
- YAFRedis最大化Web性能(yaf redis 性能)
- Web构建Redis连接简单而有效的实现方式(web 连接redis)
- Web无法连接Redis服务器(web连不上redis)
- Redis在Web开发中的光辉成就(web框架redis)
- Web与Redis哪一种优胜(web和redis哪种好)
- 抉择Web还是Redis(web和redis哪个好)
- Web应用之Redis让你的数据焕发新生(web redis应用)