gpt4 book ai didi

css - 使用 Bootstrap 4 的方形响应式 div

转载 作者:行者123 更新时间:2023-12-02 07:21:04 24 4
gpt4 key购买 nike

我想创建一个类似于 this page 的网格系统使用 Bootstrap 4。我想在 col-sm-4 中创建一个方形框,并在相同高度的 col-sm-8 中创建一个较长的矩形。我无法创建一个响应式的方形框。我怎样才能做到这一点?!

当前代码:

<div class="container">
<div class="row section-box">
<div class="col-sm-4 text-center description-text">
first square box.
</div>
<div class="col-sm-8 description-image">
second rectangle box.
</div>
</div>
</div>

我尝试过的事情:
  • Using jQuery to set the height .这不适用于 div 上的填充,并且没有响应。
  • This link我设法得到一个方形框,旁边有一个矩形,但是一旦添加了文本,它就不再是方形了。
  • 最佳答案

    您可以使用 Bootstrap 4 embed-responsive上课,就完成了

    <!doctype html>
    <html lang="en">
    <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <title>Hello, world!</title>
    </head>
    <body>
    <div class="container">
    <div class="row m-5">
    <div class="col-1">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-1</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-2">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-2</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-3">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-3</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-4">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-4</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-5">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-5</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-6">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-6</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-7">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-7</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-8">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-8</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-9">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-9</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-10">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-10</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-11">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-11</div>
    </div>
    </div>
    </div>
    <div class="row m-5">
    <div class="col-12">
    <div class="embed-responsive embed-responsive-1by1 text-center">
    <div class="embed-responsive-item bg-primary">col-12</div>
    </div>
    </div>
    </div>
    </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    </body>
    </html>

    关于css - 使用 Bootstrap 4 的方形响应式 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46266561/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com