Bootstrap: align elements to bottom of column

﹥>﹥吖頭↗ 提交于 2019-12-31 05:28:09

问题


To explain it in a short way, this is what I'm trying to achieve: 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


回答1:


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.

http://www.bootply.com/crLlXiiKqk



来源:https://stackoverflow.com/questions/26268272/bootstrap-align-elements-to-bottom-of-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!