我正在尝试相等的高度并在引导轮播上实现它以供推荐。我希望所有轮播项目的高度必须相同,但不能按预期工作。
这是示例
@import url('https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css');
body {
background: #ccc;
}
div#carousel-example-generic {
margin: auto;
max-width: 600px;
}
.carousel-inner {
display: flex;
}
.carousel-inner > .item.active{
display: flex;
}
div#carousel-example-generic p{
border: 1px solid #efefef;
padding: 40px;
}
ol.carousel-indicators {
position: static;
text-align: center;
margin: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div class="item">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the </p>
</div>
<div class="item">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has typesetting industry. Lorem Ipsum has been the </p>
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
</div>
我明白了什么?
我认为当兄弟姐妹有相同高度时不起作用,display:none
因为当我使用display: flex;
简单.item
(没有定位.item.active
)时
.carousel-inner > .item{
display: flex;
}
它按预期工作,但问题是其他项目也会显示。看这里
我的推荐是动态的,所以我不能给出固定的高度。
我正在寻找纯 CSS 解决方案。谢谢