CSS 如何将图像对齐到 div 的底部(在引导程序中)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15568829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I align images to the bottom of a div (in bootstrap)?
提问by Sheldon
I would like to be able to align different sized images to the bottom of a div.
我希望能够将不同大小的图像对齐到 div 的底部。
I have the following markup:
我有以下标记:
<div class="container">
<div class="container">
<div class="footer-images">
<a href="link1"><img src="img1"></a>
<a href="link2"><img src="img2"></a>
<a href="link3"><img src="img3"></a>
</div>
</div>
<div class="container">
<div class="copyright">
<p>? Some Company YYYY</p>
</div>
</div>
</div>
I can't figure out how to have all the images aligned to the bottom of the footer-images div. Any help would be greatly appreciated.
我不知道如何将所有图像对齐到页脚图像 div 的底部。任何帮助将不胜感激。
采纳答案by Prashobh
try this
尝试这个
.footer-images img{
vertical-align:bottom;
border:0;
}
回答by Kane
Does this help?
这有帮助吗?
<style type="text/css">
.footer-images {
margin: auto;
display: block;
position: absolute;
bottom: 0;
}
.footer-images .copyright {
text-align: center;
}
</style>
Using this HTML
使用这个 HTML
<div class="container">
<div class="container">
<div class="footer-images">
<a href="link1"><img src="http://placehold.it/350x150"></a>
<a href="link2"><img src="http://placehold.it/640x480"></a>
<a href="link3"><img src="http://placehold.it/120x120"></a>
<div class="container">
<div class="copyright">
<p>? Some Company YYYY</p>
</div>
</div>
</div>
</div>
</div>
回答by FreshSnow
In Bootstrap v4 you can use the class align-items-end
to achieve bottom alignment in a div. You can use this class on the row or on the column.
在 Bootstrap v4 中,您可以使用该类align-items-end
在 div 中实现底部对齐。您可以在行或列上使用此类。
Example with all column content aligned to the bottom.
所有列内容都与底部对齐的示例。
<div class="container">
<div class="row align-items-end">
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
</div>
</div>
Example with first column top, second colum middle and third colunm bottom alignment.
第一列顶部、第二列中间和第三列底部对齐的示例。
<div class="container">
<div class="row">
<div class="col align-self-start">
One of three columns
</div>
<div class="col align-self-center">
One of three columns
</div>
<div class="col align-self-end">
One of three columns
</div>
</div>
</div>
Source: Bootstrap documentation.
来源:Bootstrap 文档。