响应式卡片组 [英] Responsive card deck

查看:77
本文介绍了响应式卡片组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了此示例,该示例介绍了如何使用alpha 6制作响应式卡片组.在当前的Beta 2中似乎无法正常工作.有人知道如何使其在Beta 2中工作吗?

I found this example of how to make a responsive card deck using alpha 6 but it doesn't seem to work in the current beta 2. Does anybody know how to get it working in beta 2?

我需要的是一个像这样的响应式卡片组.

What I need is a responsive card deck that looks like this.

图像的大小可以变化,我对此无能为力.我希望将图像高度固定为100 px,并调整图像的大小而不会变形.正文高度应缩放至正文,行应采用最大单元格的高度.因此,基本上它应该看起来像上面的图像,但带有裁剪的图像.

The images can have varying sizes, I have no control over that. I would like the image height fixed to 100 px and the images to resize without distortion. The body height should scale to the body text and the row should take the height of the largest cell. So basically it should look like the image above but with cropped images.

这是我正在使用的确切代码:

This is the exact code I'm using:

<!DOCTYPE html>
<html lang="en">

  <head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">

    <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.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
    <script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>



  </head>

  <body>
      <div class="container">
          <div class="card-deck">
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">1 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">2 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 hidden-xs-down hidden-md-up"><!-- wrap every 2 on sm--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">3 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 hidden-sm-down hidden-lg-up"><!-- wrap every 3 on md--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">4 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 hidden-xs-down hidden-md-up"><!-- wrap every 2 on sm--></div>
              <div class="w-100 hidden-md-down hidden-xl-up"><!-- wrap every 4 on lg--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">5 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 hidden-lg-down"><!-- wrap every 5 on xl--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x300" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">6 Card title</h4>
                      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 hidden-xs-down hidden-md-up"><!-- wrap every 2 on sm--></div>
              <div class="w-100 hidden-sm-down hidden-lg-up"><!-- wrap every 3 on md--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">7 Card title</h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x300" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">8 Card title</h4>
                      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 hidden-xs-down hidden-md-up"><!-- wrap every 2 on sm--></div>
              <div class="w-100 hidden-md-down hidden-xl-up"><!-- wrap every 4 on lg--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">Card title</h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 hidden-sm-down hidden-lg-up"><!-- wrap every 3 on md--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
                  <div class="card-block">
                      <h4 class="card-title">10 Card title</h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
          </div>

      </div>
  </body>

</html>

在我的Opera浏览器中如下所示:

Which looks like this in my Opera browser:

这与示例或我上面所描述的完全不同.

This is nothing like the example or what I described above.

推荐答案

Bootstrap 4 Beta中不再存在hidden- *和visible- *类.还用卡体替换了卡块.我认为它将解决您的问题.

The hidden-* and visible-* classes no longer exist in Bootstrap 4 Beta. Also replaced card-block with card-body. I think it will solve your problem.

<!DOCTYPE html>
<html lang="en">

  <head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">

    <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.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
    <script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>



  </head>

  <body>
      <div class="container">
          <div class="card-deck">
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">1 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">2 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 d-none d-sm-block d-md-none"><!-- wrap every 2 on sm--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">3 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 d-none d-md-block d-lg-none"><!-- wrap every 3 on md--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">4 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 d-none d-sm-block d-md-none"><!-- wrap every 2 on sm--></div>
              <div class="w-100 d-none d-lg-block d-xl-none"><!-- wrap every 4 on lg--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x280" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">5 Card title</h4>
                      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 d-none d-xl-block"><!-- wrap every 5 on xl--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x300" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">6 Card title</h4>
                      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 d-none d-sm-block d-md-none"><!-- wrap every 2 on sm--></div>
              <div class="w-100 d-none d-md-block d-lg-none"><!-- wrap every 3 on md--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">7 Card title</h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x300" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">8 Card title</h4>
                      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 d-none d-sm-block d-md-none"><!-- wrap every 2 on sm--></div>
              <div class="w-100 d-none d-lg-block d-xl-none"><!-- wrap every 4 on lg--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">Card title</h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
              <div class="w-100 d-none d-md-block d-lg-none"><!-- wrap every 3 on md--></div>
              <div class="card mb-4">
                  <img class="card-img-top img-fluid" src="//placehold.it/500x270" alt="Card image cap">
                  <div class="card-body">
                      <h4 class="card-title">10 Card title</h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
                      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
              </div>
          </div>

      </div>
  </body>

这篇关于响应式卡片组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆