【发布时间】:2016-02-02 13:48:40
【问题描述】:
所以我正在处理一组内容框,每个内容框都包含一个图像、内容和容器底部的边框。现在我需要让容器的高度相等(因为它看起来更整洁)但我遇到了麻烦,因为我正在应用边框的div 在col-xx-xx div 内,因为我想要排水沟申请。
编辑:认为值得一提的是,full-height-item div 都在工作,并且它们的父级 .full-height 的 100% 高度,但是我无法让其中的 div 填写它们的父级或坐下在底部,所以我可以应用 border-bottom 或 background-color 和 div 的高度,具体取决于哪种方法最好?
这是我的标记:
.full-height {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.full-height-item {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
<ul class="full-height">
<li class="full-height-item col-md-4">
<div>
<img alt="" class="img-responsive center-block" src="url" /><br>
<span style="font-size: 1.2em; font-weight: 500; color: #0067b1">CONTENT TITLE</span><br><br>
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
<div class="full-height-item-content" style="height: 1em; background-color: black"></div>
</div>
</li>
<li class="full-height-item col-md-4">
<div>
<img alt="" class="img-responsive center-block" src="url" /><br>
<span style="font-size: 1.2em; font-weight: 500; color: #0067b1">CONTENT TITLE</span><br><br>
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
<div class="full-height-item-content" style="height: 1em; background-color: black"></div>
</div>
</li>
<li class="full-height-item col-md-4">
<div>
<img alt="" class="img-responsive center-block" src="url" /><br>
<span style="font-size: 1.2em; font-weight: 500; color: #0067b1">CONTENT TITLE</span><br><br>
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
<div class="full-height-item-content" style="height: 1em; background-color: black"></div>
</div>
</li>
</ul>
【问题讨论】:
-
所有文本都应该在
.full-height-item-contentdiv 中吗? -
嗨,不。这是一个用于在底部创建边框的 div。我不确定这是最好的方法,是否使容器 div 全高为 full-height-item 然后应用底部边框,或者添加 full-height-item-content 并将其对齐到底部。不过回顾一下,我可以看到,为了让后者工作,它需要 full-height-item-content 位于容器 div 下方,而不是在其中。
-
另外,文本没有包含在任何元素中。这使得文本块成为匿名元素,使其无法选择,因此无法设置样式(除非它可以从父级继承样式)。
-
是的,我还没有走那么远,因为我想先让功能正常工作,然后再查看内容本身。我已经使用引导程序大约一年了,这一直是我去年生活的祸根(即垂直对齐)。不过我已经到了那里,开始更好地掌握一切!
-
基本上问题是试图让未分类的 div 成为父 div 的全高(全高项),所以我可以在内容的底部应用边框,但所有边界排列在一起。我可以将边框应用于全高项目 div,因为它设置为延伸到其父 div,但因为我想要内容之间的排水沟不好。
标签: html css twitter-bootstrap-3 flexbox