代码
<template>
<view>
<view>主轴左对齐,交叉轴顶对齐,单列居中</view>
<view class="box test1">
<view class="item"></view>
<view class="item"></view>
</view>
<view>主轴右对齐,交叉轴顶对齐,单列居中</view>
<view class="box test2">
<view class="item"></view>
<view class="item"></view>
</view>
<view>主轴左对齐,交叉轴底对齐,单列居中</view>
<view class="box test3">
<view class="item"></view>
<view class="item"></view>
</view>
<view>主轴右对齐,交叉轴底对齐,单列居中</view>
<view class="box test4">
<view class="item"></view>
<view class="item"></view>
</view>
<view>主轴左对齐,交叉轴顶对齐,单列底对齐</view>
<view class="box test5">
<view class="item"></view>
<view class="item"></view>
</view>
<view>主轴左对齐,交叉轴底对齐,单列顶对齐</view>
<view class="box test6">
<view class="item"></view>
<view class="item"></view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
}
}
</script>
<style lang="scss">
.box{
width: 150rpx;
height: 150rpx;
background-color: #E7E7E7;
border-radius: 50rpx;
padding: 30rpx;
.item{
width: 30rpx;
height: 30rpx;
background-color: #333333;
border-radius: 50%;
margin: 12rpx 12rpx;
}
}
.test1{
display: flex;
justify-content: flex-start;
.item:nth-child(2){
align-self: center;
}
}
.test2{
display: flex;
justify-content: flex-end;
.item:nth-child(1){
align-self: center;
}
}
.test3{
display: flex;
justify-content: flex-start;
align-items: flex-end;
.item:nth-child(2){
align-self: center;
}
}
.test4{
display: flex;
justify-content: flex-end;
align-items: flex-end;
.item:nth-child(1){
align-self: center;
}
}
.test5{
display: flex;
justify-content: space-between;
.item:nth-child(2){
align-self: flex-end;
}
}
.test6{
display: flex;
justify-content: space-between;
align-items: flex-end;
.item:nth-child(2){
align-self: flex-start;
}
}
</style>
图示

