flex实现一行或多行文字与左右标签对齐

flex实现一行或多行文字与左右标签对齐

在这里插入图片描述


实现内容:
         .course-single {
            width: 500px;
            min-height: 48px;
            padding: 10px 0 10px 10px;
            background-color: #0c0b0b;
            display: -webkit-inline-box;
            display: -ms-inline-flexbox;
            display: inline-flex;
            -ms-flex-wrap: wrap;
            flex-wrap: wrap;
            align-items: center;
        }
        .type {
            width: 40px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            font-size: 16px;
            color: #ffffff;
            padding: 0 6px;
            border: 1px solid red;
            border-radius: 4px;
            }
            .title {
                font-size: 12px;
                margin-left: 10px;
                width: 390px;
                color: #ffffff;
        
            }
            .type-icon {
                font-size: 12px;
                width: 30px;
                height: 30px;
                text-align: center;
                line-height: 30px;
                border: 1px solid green;
                border-radius: 50%;
                color: #fff;
                margin-left: 10px;
            }

 <div class="course-single">
            <span class="type">音频</span>
            <span class="title">文字文字文字文字文字文字文字文字文字文字文字文</span>
            <span class="type-icon">40%</span>
        </div><br/>
        <div class="course-single">
            <span class="type">音频</span>
            <span class="title">文字文字文字文字文字文字文字文字文字文字文字文
                字文字文字文字文字文字文字文字文字文字文字文字文字</span>
            <span class="type-icon">40%</span>
        </div><br/>
        <div class="course-single">
            <span class="type">音频</span>
            <span class="title">文字文字文字文字文字文字文字文字文字文字文字文字
                文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文
                字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字
                文字文字文字</span>
            <span class="type-icon">40%</span>
        </div>

总结:

父盒子给:
display: inline-flex;
// 实现行内元素 Flex 布局
flex-wrap: wrap;
// flex-wrap属性定义,如果一条轴线排不下,如何换行
// wrap:换行,第一行在上方
align-items: center;
// align-items属性定义项目在交叉轴上如何对齐

子盒子给:
各个子块给相应的宽度等样式

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值