[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;
  }
}

posted @   Zhentiw  阅读(403)  评论(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工具
点击右上角即可分享
微信分享提示