我正在使用最新版本的bootstrap和brackets,我正在尝试做我的第一个网站。我想添加一个旋转木马,但它不应该像整个网站那么大。我试着在顶部/左侧/右侧/底部加一个边距以使它更小,但没有用。如果有人能帮忙,我会很高兴的。
使用bootstrap,您可以很容易地用row&;col类元素,如下所示:
<div class="row">
<div class="col-6 offset-3">
<!-- Your carousel code here -->
</div>
</div>
这将使你的旋转木马50%的宽度的页面。
请试试这个,
null
<!-- CSS only -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<div class="container">
<div class="row">
<div class="col-md-6 h-auto">
<div id="carouselExampleControls" class="carousel slide w-100 h-100 mx-auto text-center" data-ride="carousel">
<div class="carousel-inner bg-dark">
<div class="carousel-item active">
<img src="https://i.stack.imgur.com/txnXq.png" class="img-fluid w-50" alt="...">
</div>
<div class="carousel-item">
<img src="https://i.stack.imgur.com/dyPJ0.png" class="img-fluid w-50" alt="...">
</div>
<div class="carousel-item">
<img src="https://i.stack.imgur.com/4bBjx.png" class="img-fluid w-50" alt="...">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<div class="col-md-6 mt-lg-0 mt-3 h-auto mx-auto text-center">
<h4 class="h-100 bg-success d-flex align-items-center justify-content-center">Carousel side content here</h4>
</div>
</div>
</div>