如何在使用flex时在Jumbotron中垂直居中放置物品?

如何在使用flex时在Jumbotron中垂直居中放置物品?

问题描述:

我在超大屏幕尝试过这种垂直中心的所有项目,如何在使用flex时在Jumbotron中垂直居中放置物品?

display: flex; 
justify-content: center; 
align-items: center; 

但问题是所有项目都在单行列队像他们显示在线。你如何垂直居中,同时仍然以块形式显示它们。

+0

你能否提供你的代码给jumbotron。我不明白为什么你的内容不会为了jumbotron在顶部和底部应用相同数量的填充而垂直居中。 – Klooven

+0

@Klooven请再次阅读我的问题,你会明白。 – CodeMan

由于block元素垂直堆叠,因此将flex方向更改为,flex元件也会如此。

display: flex; 
flex-direction: column;    /* added */ 
justify-content: center; 
align-items: center;