CSS控制时间右对齐的一种方式

这段代码展示了如何在Angular应用中利用`ngIf`指令和Flex布局来展示不同类型的区域信息,如面积、租金、转让费、位置等,并确保时间信息始终显示在右侧。通过设置`.item-content`的`flex-grow: 1`属性,时间内容能够自适应地填充剩余空间。
摘要由CSDN通过智能技术生成
<div class="item-content-bg"
                *ngIf="item.area?.firstText?.label || item.area?.secondText?.label || item.rent || item.transferFee || item.location || item.time">
                <p class="item-content">
                    <span *ngIf="item.area?.firstText?.label" class="content area"
                      [ngStyle]="item.area?.firstText?.cssStyle | styleFilter">{{item.area?.firstText?.label}}</span>
                    <span *ngIf="item.area?.secondText?.label" class="content area"
                      [ngStyle]="item.area?.secondText?.cssStyle | styleFilter">{{item.area?.secondText?.label}}</span>
                    <span *ngIf="item.rent" class="content">{{item.rent}}</span>
                    <span *ngIf="item.transferFee" class="content">{{item.transferFee}}</span>
                    <span *ngIf="item.location" class="content">{{item.location}}</span>
                </p>
                <p *ngIf="item.time" class="content-time">{{item.time}}</p>
              </div>

 

item-content设置flex-grow 将时间撑到右边

.item-content {
    font-size: 0.75rem;
    color: rgba(133, 136, 148, 1);
    display: inline-block;
    flex-grow: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.content-time {
    font-size: 0.75rem;
    color: rgba(182, 183, 191, 1);
}

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值