gpt4 book ai didi

html - CSS对齐文本和图像

转载 作者:可可西里 更新时间:2023-11-01 13:44:39 24 4
gpt4 key购买 nike

我有一个包含 3 列的 div。在每个 div 中,我都有一个文本和一个图像。是否可以将图像对齐到同一高度?现在图像位于文本下方,但每列的文本长度不同。我想在每一列的底部都有图像。

enter image description here

谢谢,

卡罗琳

#content_row{
margin-top:150px;
margin-left:10px;
margin-right:10px;

}

#content_col{
-webkit-transform: scale(0.8);
transform: scale(0.8);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
padding-bottom: 30px;



}
#content_col:hover{
-webkit-transform: scale(1);
transform: scale(1);
-moz-box-shadow: 0 0 50px black;
-webkit-box-shadow: 0 0 50px black;
box-shadow: 0 0 50px black;
}

.tile-img{
max-width: 100%;
margin-left: auto;
margin-right:auto;
vertical-align: bottom;

}
<div class="row" id="content_row">
<div class="col-sm-4" id="content_col"><h3>Test</h3>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. </p>
<img src="https://cdn.pixabay.com/photo/2017/11/05/21/45/balloon-2921973_960_720.jpg" class="tile-img">
</div>
<div class="col-sm-4" id="content_col"><h3>Test2</h3>
<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
<img src="https://cdn.pixabay.com/photo/2017/11/05/21/45/balloon-2921973_960_720.jpg" class="tile-img">
</div>
<div class="col-sm-4" id="content_col"><h3>Test3</h3>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
<img src="https://cdn.pixabay.com/photo/2017/11/05/21/45/balloon-2921973_960_720.jpg" class="tile-img">
</div>
</div>

最佳答案

试试这个:

/* CSS used here will be applied after bootstrap.css */

#content_row {
margin-top: 150px;
margin-left: 10px;
margin-right: 10px;
display: flex; /* add the following 2 styles */
flex-direction: row;
}

#content_row>.col-sm-4 {
-webkit-transform: scale(0.8);
transform: scale(0.8);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
padding-bottom: 30px;
flex-grow: 1; /* add this to make the column grow to the height of the row */
display: flex;
flex-direction: column;
}

#content_row>.col-sm-4>p {
flex-grow: 1; /* add this to make the p take up all remaining space */
}

Example bootply

您还会注意到我已经从您的列中删除了您的 ID - ID 应该是唯一的

关于html - CSS对齐文本和图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47202150/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com