[Mobile Web] LEVEL 3: ADAPTIVE ADVENTURES -- EX
IPHONE MEDIA QUERY
We want to target a mobile device, specifically an iPhone. Write a media query
to target the iPhone's 320px
width, using the max-width
property.
@media screen and (max-width: 320px){
}
MEDIA QUERY #2
Using the media query you just wrote, stack the .logo
and <nav>
, rather than floating them to either side. Also, set the width
to inherit
from the parent and center
the text inside the <nav>
. Use the Desktop and Mobile buttons below to resize the site.
/* Logo */ .logo { float: left; width: 36.1702128%; /* 340px/940px */ } /* Navigation */ nav { float: right; }
Answer:
@media screen and (max-width: 320px) { .logo { float: none; /*IMPORTANT to set float to none*/ width: inherit; /*IMPORTANT to set width to inherit*/ } nav { float: none; text-align: center; width: inherit; } }
MEDIA SPECIFIC CONTENT
Stack the .content
and the .sidebar
, making sure their width
inherits
from the parent container. Use the Desktop and Mobile buttons below to resize the site.
.content { float: left; width: 64.893617%; /* 610px/940px */ } .sidebar { float: right; width: 31.9148936%; /* 300px/940px */ }
Answer:
@media screen and (max-width: 320px) { .content { float: none; width: inherit ; } .sidebar { float: none; text-align: center; width: inherit ; } }
MEDIA SPECIFIC NAVIGATION
Target the <nav>
<ul>
<li>
's, giving them a margin-right
of 5%
, set the text touppercase
, and set the font-size
, in ems, to a target of 13px
, with the context being 16px.
@media screen and (max-width: 320px) { nav ul li { margin-right: 5%; font-size: 0.8125em/*(13px/16px)*/; text-transform: uppercase; } }
分类:
Mobile Web
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 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工具