gpt4 book ai didi

css - 负上边距+溢出:hidden on Boostrap carousel

转载 作者:行者123 更新时间:2023-11-28 11:52:42 25 4
gpt4 key购买 nike

我有一个通用的 bootstrap v3.7 旋转木马,我正试图像这样将它拉到它上面的内容上

enter image description here

这是通过 margin-top: -50px; 在青色 div 上完成的。但是轮播的隐藏overflow属性导致顶部在div顶部上方被截断,所以我无法实现这种覆盖设计。我修改 CSS 的尝试只破坏了轮播。可以这样做吗?

最佳答案

margin-top 应该应用到包含 .carousel 的 div,也许你在调用 carousel 的 div 上使用它;

以下代码片段是您要实现的目标:

.aboveCarousel {
height: 300px;
background: magenta;
}

.container {
margin-top: -50px
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

<div class='aboveCarousel'> </div>
<div class="container">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://www.w3schools.com/bootstrap/la.jpg" alt="Los Angeles" style="width:100%;">
</div>

<div class="item">
<img src="https://www.w3schools.com/bootstrap/chicago.jpg" alt="Chicago" style="width:100%;">
</div>

<div class="item">
<img src="https://www.w3schools.com/bootstrap/ny.jpg" alt="New york" style="width:100%;">
</div>
</div>

<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>

关于css - 负上边距+溢出:hidden on Boostrap carousel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57846868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com