Twitter bootstrap 3 如何为bootstrap 3.0旋转木马项目提供自动高度

Twitter bootstrap 3 如何为bootstrap 3.0旋转木马项目提供自动高度,twitter-bootstrap-3,carousel,Twitter Bootstrap 3,Carousel,我试图使引导转盘内的图像在高度第一,宽度第二方面响应。这是因为我添加到旋转木马的图像大部分高度大于宽度,尽管我应该编写css,无论图像尺寸如何,它看起来都是一样的 我在样式上重写类,而不是修改引导样式表,因为我更喜欢使用CDN加载引导 我给我的风格添加的课程是 .carousel-inner > .item > img { position: absolute; top: 0px; left: 0px; height: auto; max-wi

我试图使引导转盘内的图像在高度第一,宽度第二方面响应。这是因为我添加到旋转木马的图像大部分高度大于宽度,尽管我应该编写css,无论图像尺寸如何,它看起来都是一样的

我在样式上重写类,而不是修改引导样式表,因为我更喜欢使用CDN加载引导

我给我的风格添加的课程是

.carousel-inner > .item > img {
    position: absolute;
    top: 0px;
    left: 0px;
    height: auto;
    max-width: 100%;
}
高度:自动和最大宽度:100%非常好用。我遇到的问题是.carousel.item的高度为500px。bootstrap.css第49行

.carousel .item {
    height: 500px;
    background-color: #777;
}
我不能给上面显示的类一个auto的高度,因为图像是不可见的。如果我把它放在这里,高度超过500px的图像会被切断,更小的图像会使旋转木马看起来不相称

在此方面的任何帮助都将不胜感激。提前谢谢。

这似乎有效

我将旋转木马放置在旋转木马容器div中,并将以下内容添加到css中:

.carousel, .carousel-inner > .item {
  display: run-in;
  width: 100%;
  height: auto!important;
}

.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
  display: block;
  height: auto;
  max-width: 100%;
  line-height: 1;
}

.carousel-container {
    margin-left:0;
}