flex布局

<!DOCTYPE html >
< html lang= "en" >
< head >
< meta charset= "UTF-8" >
< meta name= "viewport" content= "width=device-width, initial-scale=1.0" >
< meta http-equiv= "X-UA-Compatible" content= "ie=edge" >
< meta name= "viewport" content= "width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scale=0" />
< title >Document </ title >
< style >
.box{
width: 500px;
height: 500px;
margin: 50px auto;
/* 设置flex布局方式 */
display: flex;
border: 1px solid green ;
/* 设置左对齐: justify-content是指x方向 */
/* justify-content:flex-start; */
/* 右对齐 */
/* justify-content:flex-end; */
/* 居中对齐 */
/* justify-content:center; */
/* 均匀分布:space-around 两端对齐;space-between */
/* align-items:y方向上,参数和x一样 */

/* 拉伸布局:会自动撑满容器 不可以设置高度,否则没有效果*/
/* align-items: stretch */
}
.box> div{
width: 100px;
height: 100px;
font-size: 80px;
line-height: 100px;
text-align: center;
}
.box> div:nth-child( 1 ){
background-color: antiquewhite;
/* 1:flex-grow:放大比例,就是当父盒子有空余,没有被填满,该添加这个属性的盒子被放大
2:flex-shrink:缩小比例,空间不足被调用
3.flex-basis:设置固定值的大小*/
/* flex-grow:1; */
/* 三个参数:放大 缩小 固定值 */
/* flex: 1 1 50px; */
}
.box> div:nth-child( 2 ){
background-color: rgb( 103, 13, 163);
/* 设置单独的位置 设置Y轴 */
align-self: flex-end
}
.box> div:nth-child( 3 ){
background-color: rgb( 202, 20, 105)
}
.box> div:nth-child( 4 ){
background-color: rgb( 17, 182, 30)
}
.box> div:nth-child( 5 ){
background-color: rgb( 72, 80, 70)
}
< / style >
</ head >
< body >
< div class= "box" >
< div >1 </ div >
< div >2 </ div >
< div >3 </ div >
< div >4 </ div >
< div >5 </ div >
</ div >
</ body >
</ html >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值