[英]Bootstrap: how to align and center buttons at the bottom of equal-height columns
I have a three-column layout using Bootstrap 4 columns (col-sm).我有一个使用 Bootstrap 4 列 (col-sm) 的三列布局。 See codepen: https://codepen.io/anon/pen/EryRJL?editors=1100
见codepen: https ://codepen.io/anon/pen/EryRJL ? editors = 1100
I have some text in a paragraph in each column, and a button below the paragraph.我在每列的段落中有一些文本,段落下方有一个按钮。 How can I align all the buttons vertically at the bottom of the columns, while centering them in their respective columns?
如何在列底部垂直对齐所有按钮,同时将它们居中放置在各自的列中?
I can push the buttons to the bottom with我可以将按钮推到底部
.button-container {
width: 100%;
position:absolute;
bottom: 0;
text-align: center;
}
But then the centering doesn't work because width: 100% shifts the div to the right due to column padding.但是居中不起作用,因为 width: 100% 由于列填充将 div 向右移动。
I figured it out thanks to this snippet .由于这个片段,我想通了。 Instead of
width: 100%
, I simply needed left: 0
and right: 0
to fit the container properly.而不是
width: 100%
,我只需要left: 0
和right: 0
来正确地适应容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.