【问题标题】:Create 5 columns of equal height [duplicate]创建5列等高[重复]
【发布时间】:2015-10-13 19:59:05
【问题描述】:

我用引导程序创建了几列作为页脚。每列都有一些信息(即:地址、链接等)。但是其中包含更多信息的列会比另一列更长,因此所有列的排列不均匀。我该如何解决这个问题?

我的页脚:

<div class="row row-centered">
                        <div class="col-md-2 col-centered col-centered">
                            <!-- Address -->
                                <div class="" style="padding-right:0">
                                    <div class="contact-item">
                                        <div class="ci-icon">
                                            <i class="fa fa-building-o"></i>
                                        </div>
                                        <div class="ci-title font-alt">
                                            Markten
                                        </div>
                                        <div class="ci-text">
                                            Website B.V.<br>
                                            Overkampsweg 16a<br>
                                            8102 PH Raalte
                                        </div>
                                    </div>
                                </div>
                                <!-- End Address -->
                        </div>
                        <div class="col-md-2 col-centered">
                            <!-- Address -->
                                <div class="" style="padding-right:0">
                                    <div class="contact-item">
                                        <div class="ci-icon">
                                            <i class="fa fa-cube"></i>
                                        </div>
                                        <div class="ci-title font-alt">
                                            Producten
                                        </div>
                                        <div class="ci-text">
                                            <a href="http://www.website.nl/filtering.html">Filtering</a><br>
                                            <a href="http://www.website.nl/toebehoren.html">Toebehoren</a><br>
                                            <a href="http://wwww.website.nl/zacht.html">Zacht</a>
                                            <a href="http://www.website.nl/hard.html">Hard</a>
                                            <a href="http://www.website.nl/technische-gegevens.html">Technische gegevens</a>
                                        </div>
                                    </div>
                                </div>
                                <!-- End Address -->
                        </div>
                        <div class="col-md-2 col-centered">
                            <!-- Address -->
                                <div class="" style="padding-right:0">
                                    <div class="contact-item">
                                        <div class="ci-icon">
                                            <i class="fa fa-check"></i>
                                        </div>
                                        <div class="ci-title font-alt">
                                            Diensten
                                        </div>
                                        <div class="ci-text">
                                            Website B.V.<br>
                                            Overkampsweg 16a<br>
                                            8102 PH Raalte
                                        </div>
                                    </div>
                                </div>
                                <!-- End Address -->
                        </div>
                        <div class="col-md-2 col-centered">
                            <!-- Address -->
                                <div class="" style="padding-right:0">
                                    <div class="contact-item">
                                        <div class="ci-icon">
                                            <i class="fa fa-external-link"></i>
                                        </div>
                                        <div class="ci-title font-alt">
                                            Links
                                        </div>
                                        <div class="ci-text">
                                            Link 1<br>
                                            Link 2<br>
                                            Link 3
                                        </div>
                                    </div>
                                </div>
                                <!-- End Address -->
                        </div>
                        <div class="col-md-2 col-centered">
                            <!-- Address -->
                                <div class="" style="padding-right:0">
                                    <div class="contact-item">
                                        <div class="ci-icon">
                                            <i class="fa fa-map-marker"></i>
                                        </div>
                                        <div class="ci-title font-alt">
                                            Adresgegevens
                                        </div>
                                        <div class="ci-text">
                                            Website B.V.<br>
                                            Overkampsweg 16a<br>
                                            8102 PH Raalte
                                        </div>
                                    </div>
                                </div>
                                <!-- End Address -->
                        </div>
                    </div>

使用 css:

/* centered columns styles */
.row-centered {
    text-align:center;
}
.col-centered {
    display:inline-block;
    float:none;
    /* reset the text-align */
    text-align:left;
    /* inline-block space fix */
    margin-right:-4px;
}

.row-centered {
    text-align: center;
    margin-bottom: 40px;
}

Jsfiddle:

https://jsfiddle.net/L7L8dryd/

【问题讨论】:

  • 您是否尝试在 stackoverflow 上搜索解决方案?这个问题已经回答过多次了。例如herehere

标签: css twitter-bootstrap-3


【解决方案1】:

这对我来说很好,希望它能解决你的问题。

更改此类并添加表格单元格作为显示值。

.col-centered{
 display:table-cell; 
}

【讨论】:

  • 很遗憾,这没用。
  • 我再次检查,请尝试将“equal_height”类应用于所有 div。我已经更新了代码
  • 我确实将 equal_height 作为类名添加到所有 div 但它仍然对我不起作用。也许我必须补充一下,这些是 5 列。所以我使用偏移量 1。也许这不适用于您的解决方案?
  • 不不,它会正常工作,抱歉我错过了脚本中的(点)。请使用这个更新的代码..它会工作。 :)
  • 我的名声太低了,等我吃饱了再去
【解决方案2】:

您只能使用引导程序来执行此操作,see this example at bootstrap

【讨论】:

  • 不幸的是,这对我在 Firefox 中不起作用。我只需要添加那个类吗?没有 CSS?
  • 哦,是的,有一个 css,它还不是默认的(它将在 bootstrap4 中),这是 css 链接,用于引导示例:getbootstrap.com.vn/examples/equal-height-columns/… 我希望它有所帮助
  • 谢谢,但这会将列堆叠在一起:P
  • 嗯,所以,看看这是否可以帮助您stackoverflow.com/questions/32867594/… 只需将“底部”更改为“中间”,或者您可以为我们提供帮助
  • 可能跟padding-right: 0px有关?它已经在模板中,所以最好不要删除它
猜你喜欢
  • 2016-04-05
  • 1970-01-01
  • 2013-06-07
  • 1970-01-01
  • 2017-10-21
  • 2021-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多