flex布局---align-items属性,交叉轴对齐

<template>
	<view class="father">
		<view class="son">1</view>
		<view class="dauther">2</view>
		<view class="son">3</view>
		<view class="dauther">4</view>
	</view>
</template>

<script>
</script>

<style>
	.father{
		display: flex;
		/* justify-content: space-between; */
	}
	.son{
		width: 100px;
		height: 100px;
		background-color: #ff5500;
	}
	.dauther{
		width: 50px;
		height: 50px;
		background-color: #5500ff;
	}
	
</style>

刚开始的样子
在这里插入图片描述

align-items: 
flex-start | flex-end | center | baseline | stretch;

顶对齐

.father{
		display: flex;
		align-items: flex-start;
	}

在这里插入图片描述
底对齐

.father{
		display: flex;
		align-items: flex-end;
	}

居中对齐

.father{
		display: flex;
		align-items: center;
	}

在这里插入图片描述
项目的第一行文字的基线对齐

<template>
	<view class="father">
		我是项目的第一行文字
		<view class="son">1</view>
		<view class="dauther">2</view>
		<view class="son">3</view>
		<view class="dauther">4</view>
	</view>
</template>

<script>
</script>

<style>
	.father{
		display: flex;
		align-items: baseline;
	}
	.son{
		width: 100px;
		height: 100px;
		background-color: #ff5500;
	}
	.dauther{
		width: 50px;
		height: 50px;
		background-color: #5500ff;
	}
	
</style>

在这里插入图片描述如果项目未设置高度或设为auto,将占满整个容器的高度。

<style>
	.father{
		display: flex;
		align-items: stretch;
	}
	.son{
		width: 100px;
		height: 100px;
		background-color: #ff5500;
	}
	.dauther{
		width: 50px;
		/* height: 50px; */
		background-color: #5500ff;
	}
	
</style>

在这里插入图片描述
align-content属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。
应该很少用,就不整了。
至此,父元素(容器)的6个属性就到此为止了

    flex-direction
    flex-wrap
    flex-flow
    justify-content
    align-items
    align-content
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值