【问题标题】:Right alignment first column and left align second column in div of BootstrapBootstrap的div中右对齐第一列和左对齐第二列
【发布时间】:2021-07-06 23:49:08
【问题描述】:

我浏览了官方的Bootstrap grid布局页面,有很多对齐的例子。我期待着一堂课,让布局像

第一列的每个内容都以右对齐开始,第二列的每个内容都以左对齐开始。如果我们使用justify-content-center 类,那么每个内容都从中心开始。我知道如何使用 CSS 来做到这一点,但我不想对每个内容都这样做。

您是否有任何类可以将所有内容设置为正确对齐?

【问题讨论】:

  • text-righttext-left 可以做到这一点。
  • d-flex justify-content-endd-flex justify-content-start 将完成这项工作。将类与断点类一起使用。
  • @OMiShah 仅适用于单个标签,但我想要像上面所附照片一样的整个列
  • @-mhhabib 甚至@m4n0 的回答都可以。

标签: html bootstrap-4 bootstrap-grid


【解决方案1】:

我希望这就是您要找的:

来源:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="Description" content="Enter your description here"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
<title>Title</title>
</head>
<body>

    <div class="container">
        <div class="row">
          <div class="col-md text-right">
           <img src="https://via.placeholder.com/200x150/000000/FFFFFF/" />
           <h1>Hello World</h1>
           <p>Bootstrap grid</p>
          </div>
          <div class="col-md">
            <img src="https://via.placeholder.com/200x150/000000/FFFFFF/" />
            <h1>Hello World</h1>
            <p>Bootstrap grid</p>
          </div>
          
        </div>
      </div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-11
    • 1970-01-01
    • 2021-08-26
    • 2018-04-20
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多