Twitter Bootstrap网格垂直对齐底部 [英] Twitter Bootstrap grid Vertical align bottom
问题描述
所以我一直在这里,似乎永远,不能弄清楚。我有一个网格的内容不同的高度,由于图像,我想让他们所有对齐底部,但没有运气。我试过我在这里看到的,但不是,在我的jsfiddle评论
So I have been at this what seems forever and can't figure it out. I have a grid with content of different heights due to images, and I am trying to get them all to align bottom but have had no luck. I have tried what I have seen on here, but nope, commented in my jsfiddle
推荐答案
这里是你的小提琴的更新版本我想想): http://jsfiddle.net/qXT6K/34/
Here's an updated version of your fiddle with (what I think) you want: http://jsfiddle.net/qXT6K/34/
你在正确的轨道上, position:absolute; bottom:0;
;
You were on the right track with position: absolute; bottom: 0;
; it's just a matter of getting the offsets right.
我给了容器div一个高度只是为了显示底部对齐。你需要给它一个高度,否则它的所有子项绝对定位,它将默认为0.
I have given the container div a height just to show the bottom-alignment. You do need to give it a height, otherwise with all its children absolutely positioned, it will default to 0.
将容器div居中,显示为中心),您需要使用 margin-left:auto
和 margin-right:auto
$ c> margin:0 auto ),加上div上的设置宽度(在我的例子中通过类 span8
应用) float
属性,它捆绑到所有 span -
类元素中。您还需要 padding-right:40px
以容器的子项为中心,考虑 margin-left:20px
也应用于 .span -
s。
To center the container div (and so have all its children appear centered), you need to use margin-left: auto
and margin-right: auto
(shorthand margin: 0 auto
), plus a set width on the div (applied through the class span8
in my example), plus removal of the float
property which is bundled into all span-
classed elements. You also need padding-right: 40px
to center the container's children, accounting for the margin-left: 20px
which is also applied to .span-
s.
这篇关于Twitter Bootstrap网格垂直对齐底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!