简体   繁体   English

引导程序:将元素与列底部对齐

[英]Bootstrap: align elements to bottom of column

To explain it in a short way, this is what I'm trying to achieve: http://www.bootply.com/Muh7eahFC8# 为了简短地解释它,这就是我想要实现的目标: http : //www.bootply.com/Muh7eahFC8#

A responsive design, with three columns, and a button at the bottom of each column. 响应式设计,具有三列,每列底部都有一个按钮。

The problem is that I'm setting the height of the columns manually, and I'd like the whole thing to automatically adapt to the longest content of the three column. 问题是我要手动设置列的高度,并且我希望整个过程自动适应三列的最长内容。

Right now, I'm setting a different height based on the size of each viewport: 现在,我根据每个视口的大小设置不同的高度:

@media only screen and (min-width : 992px) {
  div {
    height: 180px;
  }
  div a {
    position: absolute;
    bottom: -40px;
  }
}

@media only screen and (min-width : 1200px) {
  div {
    height: 140px;
  }
}

(Give it a try on different screen width) (尝试使用其他屏幕宽度)

I think that what I'm trying to achieve is pretty common. 我认为我想要实现的目标很普遍。 Isn't there a smarter wayt to achieve it? 是否有更明智的方法来实现?

-- edit -编辑

With @DavidG help I could fins a responsive solution: http://www.bootply.com/7C2WvyxNyZ unfortunately hte 33% is hardcoded, if I change the number of columns I'll have to update the css, and I found NO WAY to center the buttons in each column 借助@DavidG的帮助,我可以找到一个响应式的解决方案:不幸的是,如果更改了必须更新css的列数,则http://www.bootply.com/7C2WvyxNyZ硬编码为33%,但是我发现没有办法使按钮在每一列居中

Can't remember where I got this snippet from but this will make your columns the same height: 不记得我从何处获得此摘要,但这会使您的列具有相同的高度:

.row {
    display: table;
}

[class*="col-"] {
    float: none;
    display: table-cell;
    vertical-align: top;
}

Then with a couple of tweaks, you can force the anchors to be fixed to the bottom of the div. 然后通过一些调整,可以强制将锚点固定到div的底部。

http://www.bootply.com/crLlXiiKqk http://www.bootply.com/crLlXiiKqk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM