flex布局

flex-direction:row

 <div class="container">
      <p>one</p>
      <p>two</p>
      <p>three</p>
   </div>
   
.container{
  margin:20px 20px;
  width:300px;
  height:200px;
  box-sizing: border-box;
  padding: 5px 5px;
  background: #fff;
  display:flex;
  flex-direction: row;
}
p{
  background: greenyellow;
  margin: 2px 2px;
  height:20px;
}

在这里插入图片描述
flex-direction:row-reverse
在这里插入图片描述
flex-direction:column

<div class="container">
      <p>one</p>
      <p>two</p>
      <p>three</p>
 </div>

.container{
  margin:20px 20px;
  width:300px;
  height:200px;
  box-sizing: border-box;
  padding: 5px 5px;
  background: #fff;
  display:flex;
  flex-direction: column;
}
p{
  background: greenyellow;
  margin: 2px 2px;
  height:20px;
}

在这里插入图片描述
flex-direction:column-reverse
在这里插入图片描述
align-items属性有助于将项目定位在垂直于项目主轴的横轴上。
有四个不同的值:stretch、flex-start、flex-end、center
默认设置的是stretch,这就是为什么容器中的项目会自动拉伸到与容器相同的高度(直观上宽度,因为设置的与主轴垂直的,主轴现在变成column,所以设置的是row)
接着flex-direction:coumn举例子、
align-items:flex-start

.container{
  margin:20px 20px;
  width:300px;
  height:200px;
  box-sizing: border-box;
  padding: 5px 5px;
  background: #fff;
  display:flex;
  flex-direction: column;
  align-items: flex-start;
}
p{
  background: greenyellow;
  margin: 2px 2px;
  height:20px;
}

在这里插入图片描述
align-items:center
在这里插入图片描述

align-items:flex-end
在这里插入图片描述
justify-content 属性
jusify-content属性作用于主轴上对齐项目,这与容器中的项目相同,它有六个不同的值:flex-start、flex-end、center、space-around、space-between、space-evenly
flex-start、flex-end、center的作用与它们应用于align-items属性时的作用相同,只是在主轴上而不是垂直于主轴。

justify-content:center
在这里插入图片描述
justify-content:space-around
在这里插入图片描述
justify-content:space-between
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值