如何使用CSS flexbox垂直对齐和拉伸内容 [英] How to vertically align and stretch content using CSS flexbox

查看:286
本文介绍了如何使用CSS flexbox垂直对齐和拉伸内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CSS flexbox,如何在不使用css height 属性的情况下,将所有div的内容垂直居中放置在同一行上,

详情 - http://jsbin.com/ efaCEVa / 1 / edit

解决方案

HTML



 < div class ='outer'> 
< div class ='inner'> A< / div>
< div class ='inner'> B< / div>
< div class ='inner'> C< / div>
< / div>



CSS



  .outer {
align-items:stretch;
display:flex;
}

.inner {
align-items:center;
display:flex;
}


Using CSS flexbox, how can I simultaneously vertically center the content of all divs in a row while keeping the same height on all of them without using the css height attribute?

Details — http://jsbin.com/efaCEVa/1/edit

解决方案

HTML

<div class='outer'>
    <div class='inner'>A</div>
    <div class='inner'>B</div>
    <div class='inner'>C</div>
</div>

CSS

.outer {
    align-items: stretch;
    display: flex;
}

.inner {
    align-items: center;
    display: flex;
}

这篇关于如何使用CSS flexbox垂直对齐和拉伸内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆