css 响应式布局

本文详细介绍了如何使用CSS媒体查询实现在不同屏幕尺寸下网页布局的自适应调整,重点讲解了在屏幕宽度小于1000px时,如何通过隐藏右侧布局并重新分配内容至主区域,以提供更佳的移动设备浏览体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

html{
  font-size: calc(100vw/50);
}

.robot-index-head,
.robot-index-main
.robot-index-footer
{
  height: 4rem;
  width: 100%;
}
.robot-index-head
{
  line-height: 4rem;
}
.robot-index-head img
{
  width: 25rem;
}
.robot-index-main{
  height: calc(100vh - 7rem);
  overflow: hidden;
}
.robot-index-footer{
  width: 100%;
  height: 3rem;
  line-height: 3rem;
  position: fixed;
  left: 0;
  bottom: 0;
}
.robot-main{
  height: 100%;
  width: 70%;
  overflow: hidden;
}
.robot-right{
  height: 100%;
  width: 30%;
  overflow: hidden;
}
.robot-main-right{
    display: none;
}
@media only screen and (max-width: 1000px) {
  /* 竖屏模式 */
  .robot-right{
    display: none;
  }
  .robot-main{
    width: 100%;
  }
  .robot-main-right{
    display: block;
  }
}

主要就是 @media only screen and (max-width: 1000px)这块,就是在最大宽度1000px以下都生效的样式,隐藏右侧布局,同时可以显示右侧的内容到robot-main-right,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值