[英]How to align an element to the bottom of the div with flexbox when flex-direction is set to column
I know this question has been asked several times, but for some reason my isn't working.我知道这个问题已经被问过好几次了,但由于某种原因我没有工作。 Can you guys please help me?I'm just trying to align all the buttons with all the cards because the tiles could have different lengths one, two or three lines, but I don't know why it's not working.
你们能帮我吗?我只是想将所有按钮与所有卡片对齐,因为瓷砖可能有不同的长度,一、二或三行,但我不知道为什么它不起作用。 Thanks!
谢谢!
.cards { max-width: 1200px; display: flex; } .card { flex: 1; margin-right: 30px; } .content { display: flex; flex-direction: column; justify-content: space-between; } .pic { min-height: 20vh; background: blue; }
<div class="cards"> <div class="card red"> <div class="pic"> </div> <div class="content"> <h1>Lorem ipsum dolor sit ait.Lorem ipsum dolor sit ait </h1> <button>click here</button> </div> </div> <div class="card blue"> <div class="pic"> </div> <div class="content"> <h1>Lorem ipsum dolor sit ait. </h1> <button>click here</button> </div> </div> </div>
For use the justify-content: space-between;
使用
justify-content: space-between;
property, a height
or width
must be defined.属性,必须定义
height
或width
。
For flex-direction:column
is must be defined height
对于
flex-direction:column
必须定义height
.cards { max-width: 1200px; display: flex; } .card { flex: 1; margin-right: 30px; } .content { display: flex; flex-direction: column; justify-content: space-between; height:200px; } .pic { min-height: 20vh; background: blue; }
<div class="cards"> <div class="card red"> <div class="pic"> </div> <div class="content"> <h1>Lorem ipsum dolor sit ait.Lorem ipsum dolor sit ait </h1> <button>click here</button> </div> </div> <div class="card blue"> <div class="pic"> </div> <div class="content"> <h1>Lorem ipsum dolor sit ait. </h1> <button>click here</button> </div> </div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.