我的旋转木马进入全屏模式,但我希望它的尺寸要小一些,例如在左右两侧留一个边距,这样它就不会占据整个页面。使用CSS进行了尝试,但到目前为止还没有运气。
<section id="slider">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active"> <img class="d-block w-100" src="wildfire1.jpg" alt="waldbrband1"> </div>
<div class="carousel-item"> <img class="d-block w-100" src="wildfire2.jpg" alt="waldbrand2"> </div>
<div class="carousel-item"> <img class="d-block w-100" src="wildfire3.jpg" alt="waldbrand3"> </div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a>
</div>
</section>
答案 0 :(得分:0)
我不确定这是最好的方法,但是您可以将代码放在这样的容器中:
<div class="MySlider-container">
<section id="slider">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active"> <img class="d-block w-100" src="wildfire1.jpg" alt="waldbrband1"> </div>
<div class="carousel-item"> <img class="d-block w-100" src="wildfire2.jpg" alt="waldbrand2"> </div>
<div class="carousel-item"> <img class="d-block w-100" src="wildfire3.jpg" alt="waldbrand3"> </div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#carouselExampleIndicators"
role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a>
</div>
</section>
</div>
您的CSS代码看起来像这样:
.MySlider-container {
margin-left: 5rem;
margin-right: 5rem;
}