【问题标题】:Bootstrap carousel image out of frame引导轮播图像超出框架
【发布时间】:2025-12-12 17:35:01
【问题描述】:
我在使用 Bootstrap 轮播时遇到问题。我的旋转木马的边缘是圆角的,但是当图像滑动时,会出现图像的一角。我无法用言语来解释。
这是一个正常且正确的圆角轮播图像。
但是当图像滑到另一个图像时,它会超出框架并形成实心边缘。
有没有办法使用 Bootstrap 3 来解决这个问题?
谢谢你,里查兹。
【问题讨论】:
标签:
javascript
html
css
twitter-bootstrap
carousel
【解决方案1】:
我相信您看到的“实心边缘”是半透明的“控件”。我夸大了它们以使效果更明显。您可能希望根据自己的喜好调整他们的样式。我建议移除渐变背景并改用文本阴影来帮助控件脱颖而出。
.carousel {
padding-top: 1em;
padding-bottom: 1em;
width: 350px;
margin: auto;
background-color: transparent;
}
.carousel .item img {
border-radius: 64px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- 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>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active"><img src="http://placehold.it/350x150" alt="..."></div>
<div class="item"><img src="http://placehold.it/350x150" alt="..."></div>
<div class="item"><img src="http://placehold.it/350x150" alt="..."></div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>