通常,我总是在编程方面不知所措,但是我正在尽力而为。请友好一点!
我在YouTube上观看了一个不错的教程,目的是在Django项目中为自己制作轮播。
但不是一次只显示一张图像,而是将所有三个图像堆叠在一起。我敢肯定我错过了一些简单的事情。
请帮助我以最少的代码更改来解决此问题。
这是我当前的HTML代码。我不认为CSS在这一点上很重要:
<div class="container-fluid" id="main-container">
<div class="row">
<div class="col-sm-12">
<div id="slider" class="carousel slide" data-ride="carousel">
<!-- indicators (dot nav): -->
<ol class="carousel-indicators">
<li data-target="#slider" data-slide-to="0" class="active"></li>
<li data-target="#slider" data-slide-to="1"></li>
<li data-target="#slider" data-slide-to="2"></li>
</ol>
<!-- wrapper for slides: -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-fluid" src='{% static "images/carousel1.jpg" %}' alt="string players"/>
<div class="carousel-caption">
<h1>Text here</h1>
</div>
</div>
<div class="item">
<img class="img-fluid" src='{% static "images/carousel2.jpg" %}' alt="string players"/>
<div class="carousel-caption">
<h1>More text here</h1>
</div>
</div>
<div class="item">
<img class="img-fluid" src='{% static "images/carousel3.jpg" %}' alt="string players"/>
<div class="carousel-caption">
<h1>Even more text here</h1>
</div>
</div>
</div>
<!-- next/prev navigation controls: -->
<a class="left carousel-control" href="#slider" 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="#slider" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
如果问题出在Bootstrap的版本上,这是我的meta,它具有我在项目中使用的Bootstrap的版本:
<head>
<title>HCMN : {{ page_name }}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Load CSNs (same for all templates): -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<!-- Load CSS files (from each template): -->
{% block load_css %}
{% endblock %}
非常感谢您的帮助!
答案 0 :(得分:0)
啊哈!没关系。我需要将“ carousel-item”作为一个类,而不是“ carousel”!当我可以回答自己的问题时,我会喜欢它。