【问题标题】:Decrease one columns height bootstrap减少一列高度引导
【发布时间】:2021-03-14 10:50:02
【问题描述】:

我想要实现的是使用引导程序进行这样的页脚设计:

我已经设法设置页脚的左栏(红色背景)。问题是,不知何故我无法设置右列(黑色背景)的样式。一旦我将高度设置为 70%,列高就会缩小到内容。我看到这与没有为父容器设置高度有关。但是我怎样才能设置一个固定的高度,并且仍然保持响应能力呢?使用媒体查询?

此外,只要我将显示设置为包含 2 行(一个带有链接,一个带有白色徽标)的右列的显示,这些行就会显示为彼此相邻的列。如果我不这样做,内容对齐就没有效果。

谁能帮我解决这个问题?似乎我错过了有关网格系统和显示实用程序的一些重要信息。

这就是现在的样子:

这是我的代码:

<footer class="mt-auto" role="contentinfo">
<div class="container-fluid h-100">
    <div class="row footerContainer d-flex h-100">

        <div class="footerLeftCol col-12 col-md-7">

            <div class="row pl-5 justify-content-center">
                <div class="col-12 mt-3 mb-3"><img
                            src="<?php echo get_stylesheet_directory_uri(); ?>/images/logo_white.png"></div>
            </div>

            <div class="row align-items-center text-center">

                <div class="col-12 col-md-6 contactColLeft">
                   
                </div>

                <div class="col-12 col-md-6">
                   
                </div>
            </div>

            <div class="row text-center mt-3 pb-3">
                <div class="col-12">
                    <a><i class="fab fa-instagram fa-lg mr-2"></i></a>
                    <a><i class="fab fa-facebook-square fa-lg"></i></a>
                </div>
            </div>

            <div class="col-md-12 copyright">
                <p class="text-center pt-2">&copy; Copyright <?php echo date( 'Y' );  ?> - All rights
                    reserved.</p>
            </div>

        </div>

        <div class="footerRightCol d-flex col-12 col-md-5">

            <div class="row text-center align-items-center justify-content-center ">
                <div class="col-12 flex-grow-1">
                    <h4> Impressum </h4>
                    <h4> Datenschutz </h4>
                    <h4> Sitemap </h4>
                </div>
            </div>

            <div class="row  flex-grow-1 justify-content-end mr-3 mt-auto text-center">

                <div class="col-6">
                    <h4> Designed by </h4>
                </div>
                <div class="col-6">
                    <img src="<?php echo get_stylesheet_directory_uri()?>/images/logo_fewture.png" style="height: 50px">
                </div>
            </div>
        </div>

    </div>
</div>

【问题讨论】:

    标签: html css twitter-bootstrap bootstrap-4 flexbox


    【解决方案1】:

    您可以将第二列设置为display: flex 并使用flex-direction: columnjustify-content-end 进行定义。

    把你的内容放在第二列div里面,内容会从底部开始增长。

    .box-1 {
      height: 400px;
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
    <div class="container">
      <div class="row border border-primary p-2">
        <div class="col-12 col-md-6 border border-secondary box-1">Column 1</div>
        <div class="col-12 col-md-6 border border-secondary d-flex flex-column justify-content-end p-2">
          <div class="border border-danger p-2"/>
            <p>As the content is growing</p>
            <p>Justify content end with</p>
            <p>Flex direction column</p>
            <p>Will make content growing up :)</p>
          </div>
        </div>
      </div>
    </div>

    【讨论】:

    • 我需要让内容居中对齐。另外我不知道如何将右列(黑色背景)的高度降低到低于左列(红色背景)的高度......
    • 我建议避免设置元素的高度。相反,让 flexbox 为你做这件事。在此解决方案中,右列将从下到上增长。所以右栏内容总是会低于左栏(除非增长太多)。然后,您可以在右列 div 中插入一个带有display: flex 的新 div,并将 flexbox 属性设置为居中对齐内容。
    猜你喜欢
    • 2014-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-21
    • 2015-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多