flex 布局设置最后一个元素靠右 margin-left: auto

该博客介绍了如何使用CSS的Flex布局属性来排列元素。示例中,`.parent`设置为Flex容器,使得`.son1`、`.son2`和`.son3`子元素按中心对齐。`.son1`和`.son2`左侧有10px的外边距,`.son3`通过`margin-left:auto`和`margin-right:10px`实现了右对齐。这种布局方式常用于响应式设计和复杂网页组件的排版。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

示例

<div class="parent">
	<div class='son1'>A</div>
	<div class='son2'>B</div>
	<div class='son3'>C</div>
</div>
	.parent {
		display: flex;  ⭐️⭐️⭐️
		align-items:center;
		width: 300px;
		height: 50px;
		border: 1px solid black;
	}
	
	.son1,.son2,.son3 {
		height: 30px;
		line-height: 30px;
		width: 30px;
		border: 1px solid black;
		border-radius: 4px;
		text-align: center;
	}
	
	.son1,.son2 {
		margin-left: 10px;
	}
	.son3 {
		margin-left: auto;   ⭐️⭐️⭐️
		margin-right: 10px;
	}

``` <view v-if="currentTab === 3" class="list"> 11111 <!-- 查询条件容器 --> <view class="query-condition"> <!-- 标题 --> <text class="section-title" style="margin-left: 20rpx;">查询条件</text> <!-- 条件输入行 --> <view class="input-row"> <!-- 商家名称部分 --> <view class="input-group"> <text class="label">商家名称</text> <input class="input" type="text" placeholder="请输入" style="margin-left: 20rpx; width: 200rpx;" /> </view> <!-- 计费日期部分 --> <view class="date-group" style="margin-left: 40rpx;"> <text class="label">计费日期</text> <input class="date-input" type="month" style="margin-left: 20rpx; width: 200rpx;" /> <text style="margin: 0 10rpx;">至</text> <input class="date-input" type="month" style="width: 200rpx;" /> </view> <!-- 操作按钮 --> <view class="action-buttons" style="margin-left: auto;"> <button class="btn reset-btn" @click="handleReset" style="margin-right: 30rpx;" >重置</button> <button class="btn query-btn" @click="handleQuery" >查询</button> </view> </view> </view> </view>```查询条件 ,左上角(上左有点距离)然后中间内容:商家名称后面是个input可以选择的输入框,后面是 计费日期,可以选择几月到几月,有点距离跟前面的input,然后后面有俩个按钮重置和查询重置白色背景黑色字体,查询蓝色背景白色字体位置最靠有但也有点距离,按钮跟前两个都是在一行,这个是我要的位置,现在位置全乱了,可能是大小原因导致换行什么的,帮我改下
04-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值