web移动端布局

web移动端布局

1.基础准备

<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0,minimum-scale=1.0">
*{
    margin:0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
input{
    -webkit-appearance: none;
}
img,a{
    -webkit-touch-callout: none;
}
body{
    width: 100%;
    max-width: 1080px;
    min-width: 320px;
    margin: 0 auto;
    background-color: #f6f6f6;
    font-size: 14px;
    line-height: 1.5;
    color: #666;
    font-family: -apple-system,Helvetica,sans-serif;
}

2.流式布局

主体宽度设为100%;元素根据实际情况调整百分比

3.flex布局

父元素设置为display:flex;并在父元素进行相应设置,子元素按需填写flex:1或者flex:50%;

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    div{
     
      width: 600px;
      height: 400px;
      background-color: pink;
      display: flex;
      /*盒子方向,默认从左往右,默认为row*/
      /*flex-direction: row;*/
      /*翻转*/
      /*flex-direction: row-reverse;*/
      /*从上往下*/
      /*flex-direction: column;*/
      /*从下往上*/
      /*flex-direction: column-reverse;*/

      /*设置主轴上子元素排列方式,默认flex-start左对齐*/
      /*justify-content: flex-start;*/
      /*flex-end右对齐*/
      /*justify-content:flex-end;*/
      /*center居中对齐*/
      /*justify-content: center;*/
      /*space-around平分剩余空间*/
      /*justify-content: space-around;*/
      /*space-between两头贴边再平分*/
      /*justify-content: space-between;*/

      /*flex默认不换行,所有子元素排列在一行,会调整子元素的宽度*/
      /*flex-wrap: nowrap;*/
      /*wrap换行*/
      /*flex-wrap: wrap;*/

      /*align-items:center侧轴居中*/
      /*align-items: center;*/
      /*stretch拉伸,子元素不能设置高度*/
      /*align-items: stretch;*/

      /*当盒子出现换行时,可以使用align-content,实现两行盒子贴边对齐等*/
      /*flex-wrap: wrap;
      align-content: space-between;*/

    } 
    div span{
     
      width: 150px;
      height: 150px;
      background-color:blue;
    }
  </style>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值