HTML   发布时间:2022-04-14  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了html – 使用Flexbox对齐角落中的元素大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用Flexbox在Flex容器的四个角落放置四个元素,我正在努力.我无法弄清楚如何证明单个flex-items的内容.每次我尝试,它最终将flex-container的所有内容放到左侧或右侧(或顶部/底部,取决于主轴).

HTML

<div class="container">
    <div class="top-left">
         TL
    </div>
    <div class="top-right">
        TR
    </div>
    <div class="bottom-left">
        BL
    </div>
    <div class="bottom-right">
       BR
    </div>
</div>

这是我的CSS:

.container {
    display: -webkit-flex;
    background-color:#ccc;
}

.top-left {
 /* ? */
}

.top-right {

}

.bottom-left {

}

.bottom-right {

}

这是一个小提琴,说明我正在尝试做什么:

http://jsfiddle.net/JWNmZ/8/

解决方法

这是一种方法(为清晰起见,省略了前缀): http://jsfiddle.net/JWNmZ/10/
.container {
    display: flex;
    flex-wrap: wrap;
    background-color:#ccc;
}

.top-left {
    flex: 50%; 
}

.top-right {
    flex: 50%;
    text-align: right;
}

.bottom-left {
    flex: 50%;
}

.bottom-right {
    flex: 50%;
    text-align: right;
}

大佬总结

以上是大佬教程为你收集整理的html – 使用Flexbox对齐角落中的元素全部内容,希望文章能够帮你解决html – 使用Flexbox对齐角落中的元素所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: