html - 如何使 Bootstrap "Cards"响应

标签 html css twitter-bootstrap

Bootstrap 最近提供了一个名为“卡片”的功能,在到达 747px 视口(viewport)之前,一切都很酷。请参见下图。

enter image description here

如您所见,一切都乱七八糟,容器放不下。是否有任何 CSS 修复可以确保它们在 747 像素及以下看起来不错???

这是我的 HTML:

<div class="row">
    <div class="col-md-3">
    <div class="card">
      <img class="card-img-top" src="img/card1.jpg" alt="Card image cap">
      <div class="card-block">
        <h4 class="card-title">This is Card #1</h4>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
        <a href="http://v4-alpha.getbootstrap.com/components/card/" class="btn btn-primary">Learn More</a>
    </div>
    </div>
</div>

<div class="col-md-3">
    <div class="card card-inverse card-primary text-center">
      <img class="card-img-top" src="img/card2.jpg" alt="Card image cap">
      <div class="card-block">
        <h4 class="card-title">This is Card #2</h4>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
        <a href="http://v4-alpha.getbootstrap.com/components/card/" class="btn btn-primary">Learn More</a>
    </div>
    </div>
</div>


<div class="col-md-3">
    <div class="card card-inverse card-success text-center">
      <img class="card-img-top" src="img/card3.jpg" alt="Card image cap">
      <div class="card-block">
        <h4 class="card-title">This is Card #3</h4>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
        <a href="http://v4-alpha.getbootstrap.com/components/card/" class="btn btn-primary">Learn More</a>
    </div>
    </div>
</div>

<div class="col-md-3">
    <div class="card card-inverse card-info text-center">
      <img class="card-img-top" src="img/card4.jpg" alt="Card image cap">
      <div class="card-block">
        <h4 class="card-title">This is Card #4</h4>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
        <a href="http://v4-alpha.getbootstrap.com/components/card/" class="btn btn-primary">Learn More</a>
    </div>
    </div>
</div>

</div>

查看我的 JSFIDDLE:https://jsfiddle.net/a9wav5g1/1/

有什么想法吗???如何解决这个问题?

最佳答案

如果您只是谈论不适合包含 div 的图像,只需添加

img{
  width:100%;
  height:auto;
}

到您需要的图像img-responsive

Codepen http://codepen.io/noobskie/pen/WQQZVQ?editors=110

更具体地说

.card-img-top{
  width:100%;
  height:auto;
}

对于conatiner div,如果你需要它的全 Angular ,只需添加<div class="container-fluid">

关于html - 如何使 Bootstrap "Cards"响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32516886/

相关文章:

html - 增加标签并悬停在更大的高度

html - 选择标记中的向下箭头图标

javascript - Camera slideshow v1.3.3-调整图片大小

javascript - 如何使 Bootstrap 多个选项卡组共享相同的ID

javascript - 如何从其他站点下载mp3文件

javascript - 如何在图像src ionic中使用变量

css - 为什么 div 不在页面中心?

jquery - 将类应用于控制 'next' 、 'previous' 和 'close' 的 Fancybox 链接/按钮

javascript - 渲染事件后的 LessCSS

css - Bootstrap css 中的列排序