Bootstrap img-responsive和缩略图类有什么区别?

时间:2017-03-22 08:24:50

标签: html css twitter-bootstrap twitter-bootstrap-3

我已经在两个不同的项目中使用了两个,但我似乎无法看到两者之间的区别。 img-responsive看起来很混乱,但我仍然不知道他们究竟做了什么以及他们有何不同?

Project 1class="thumbnail"
Project 2class="img-responsive"

2 个答案:

答案 0 :(得分:1)

.img-responsive类将max-width:100%,height:auto和display:block应用于图像,有效地使其缩放到其父容器的宽度。

.img-thumbnail类将样式应用于图像,包括填充和边框

答案 1 :(得分:1)

来自Bootstrap源代码:

.img-responsive {
    display: inline-block;
    height: auto;
    max-width: 100%;
}

.thumbnail {
  display: block;
  padding: 4px;
  margin-bottom: 20px;
  line-height: 1.42857143;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  -webkit-transition: border .2s ease-in-out;
       -o-transition: border .2s ease-in-out;
          transition: border .2s ease-in-out;
}
相关问题