Bootstrap v4.0.0-alpha.6卡组内容未对齐到顶部

时间:2017-02-11 19:06:54

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

使用Bootstrap v4.0.0-alpha.6网站上的CDN,我无法解决flexbox将卡片内容点亮到顶部:card-group content not aligned to top

当我将align-items-start添加到card-group时,就像这样:

<div class="card-group align-items-start">

卡片对齐方式有所改进,然后边框框格不在线,缺少以前加入的片段:<code>card-group borders mis-aligned</code>

bootstrap-4a6发布版没有样式表更改。这是我的HTML:

<section id="what-we-do" style="padding: 20px 0px;">
  <div class="section-content">
    <div class="container">
      <h2>What we do</h2>
      <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
      tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
      quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
      consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
      cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
      proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      <div class="row">
        <div class="col-sm-12">
          <div class="card-group align-items-start">
            <div class="card">
              <div class="card-block">
                <h4 class="card-title">Strategy &amp; Planning</h4>
                <h6 class="card-subtitle">Support card subtitle</h6>
              </div>
              <img class="card-img-top img-fluid" src="img/chalkboard.jpg" alt="a chalkboard">
              <div class="card-block">
                <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam repellendus est rerum sed, aliquid inventore, voluptate, eveniet, soluta nostrum distinctio cupiditate adipisci sint! Natus consequuntur non distinctio perferendis, quibusdam, quasi!</p>
                <button type="button" class="btn btn-success-outline" data-toggle="modal" data-target="#myModal">learn more</button>
              </div>
            </div>
            <div class="card">
              <div class="card-block">
                <h4 class="card-title">Creative &amp; Design</h4>
                <h6 class="card-subtitle">Support card subtitle</h6>
              </div>
              <img class="card-img-bottom img-fluid" src="img/working.jpg" alt="working on a laptop">
                <div class="card-block">
                  <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed alias maxime fugiat error doloribus eum, aliquam deserunt ut sequi asperiores iure natus blanditiis commodi eveniet ipsam veniam eius eos. Sit!  Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam repellendus est rerum sed, aliquid inventore, voluptate, eveniet, soluta nostrum distinctio cupiditate adipisci sint! Natus consequuntur non distinctio perferendis, quibusdam, quasi!</p>
                  <button type="button" class="btn btn-success-outline" data-toggle="modal" data-target="#myModal">learn more</button>
                </div>
            </div>
            <div class="card">
              <div class="card-block">
                <h4 class="card-title">Programming &amp; Technical</h4>
                <h6 class="card-subtitle">Support card subtitle</h6>
              </div>
              <img class="card-img-bottom img-fluid" src="img/programming.jpg" alt="fingers typing on a keyboard">
                <div class="card-block">
                  <p class="card-text">Numquam repellendus est rerum sed, aliquid inventore, voluptate, eveniet, soluta nostrum distinctio cupiditate adipisci sint! Natus consequuntur non distinctio perferendis, quibusdam, quasi!</p>
                  <button type="button" class="btn btn-success-outline" data-toggle="modal" data-target="#myModal">learn more</button>
                </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

2 个答案:

答案 0 :(得分:0)

由于card-blockflex-grow: 1,因此每张卡中的2 card-block平均增长以填充图像上方和下方的空间。由于您只希望底部card-block增长,因此请使用简单的填充div(<div class="p-3">)来保留card-titlecard-subtitle而不是card-block

<div class="card">
       <div class="p-3">
            <h4 class="card-title">Strategy &amp; Planning</h4>
            <h6 class="card-subtitle">Support card subtitle</h6>
       </div>
       <img class="img-fluid" src="//placehold.it/600" alt="a chalkboard">
       <div class="card-block">
          <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipsicing elit. Numquam repellendus est rerum sed, aliquid inventore, voluptate, eveniet, soluta nostrum distinctio cupiditate adipisci sint! Natus consequuntur non distinctio perferendis, quibusdam, quasi!</p>
          <button type="button" class="btn btn-success-outline" data-toggle="modal" data-target="#myModal">learn more</button>
       </div>
</div>

http://www.codeply.com/go/PyEJ1a6Rk4

答案 1 :(得分:0)

分离的.card-block是问题所在。相反,将所有内容集中到一个.card-block将解决您的问题。

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>

<section id="what-we-do" style="padding: 20px 0px;">
    <div class="section-content">
        <div class="container">
            <h2>What we do</h2>
            <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
            <div class="row">
                <div class="col-sm-12">
                    <div class="card-group">
                        <div class="card">
                            <div class="card-block">
                                <h4 class="card-title">Strategy &amp; Planning</h4>
                                <h6 class="card-subtitle">Support card subtitle</h6>
                                <img class="card-img-top img-fluid" src="img/chalkboard.jpg" alt="a chalkboard">
                                <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam
                                    repellendus est rerum sed, aliquid inventore, voluptate, eveniet, soluta nostrum
                                    distinctio cupiditate adipisci sint! Natus consequuntur non distinctio perferendis,
                                    quibusdam, quasi!</p>
                                <button type="button" class="btn btn-success-outline" data-toggle="modal"
                                        data-target="#myModal">learn more
                                </button>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-block">
                                <h4 class="card-title">Creative &amp; Design</h4>
                                <h6 class="card-subtitle">Support card subtitle</h6>
                                <img class="card-img-bottom img-fluid" src="img/working.jpg" alt="working on a laptop">
                                <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed alias
                                    maxime fugiat error doloribus eum, aliquam deserunt ut sequi asperiores iure natus
                                    blanditiis commodi eveniet ipsam veniam eius eos. Sit! Lorem ipsum dolor sit amet,
                                    consectetur adipisicing elit. Numquam repellendus est rerum sed, aliquid inventore,
                                    voluptate, eveniet, soluta nostrum distinctio cupiditate adipisci sint! Natus
                                    consequuntur non distinctio perferendis, quibusdam, quasi!</p>
                                <button type="button" class="btn btn-success-outline" data-toggle="modal"
                                        data-target="#myModal">learn more
                                </button>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-block">
                                <h4 class="card-title">Programming &amp; Technical</h4>
                                <h6 class="card-subtitle">Support card subtitle</h6>
                                <img class="card-img-bottom img-fluid" src="img/programming.jpg"
                                     alt="fingers typing on a keyboard">
                                <p class="card-text">Numquam repellendus est rerum sed, aliquid inventore, voluptate,
                                    eveniet, soluta nostrum distinctio cupiditate adipisci sint! Natus consequuntur non
                                    distinctio perferendis, quibusdam, quasi!</p>
                                <button type="button" class="btn btn-success-outline" data-toggle="modal"
                                        data-target="#myModal">learn more
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
&#13;
&#13;
&#13;