我正在尝试将Carousel Bootstrap 4实施到个人项目中。我对HTML5,CSS3,Bootstrap 4和JS有基本的了解。我已经看了几个关于如何使用轮播组件的讨论和教程,但无法在浏览器中获得正确的输出。我使用chrome和firefox,并且在两个浏览器中都有同样的问题。我已经检查了(链接)和(脚本)的路径,我甚至不得不将(img data-src =“#”)更改为(img src =“#”),以便图像可以正确加载到浏览器中。图像相互叠加,不知道如何解决这个问题。我直接从Bootstrap网站复制代码。这是我第一次参加社区活动和第一个问题。只是对这个组件感到有点沮丧。
提前致谢!
Image example of problem in browser
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Carousel-testing!</title>
<link rel="stylesheet" href="assets\css\bootstrap.css">
<link rel="stylesheet" href="assets\css\bootstrap-theme.css">
<link rel="stylesheet" href="assets\css\app.css">
<link rel="stylesheet" href="assets\css\animate.css">
<script type="text/javascript" src="assets\js\jquery.js"></script>
<script type="text/javascript" src="assets\js\bootstrap.js"></script>
<script type="text/javascript" src="assets\js\app.js"></script>
</head>
<nav>
</nav>
<section id="carousel">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<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>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img src="assets\images\2736779-casino-roulette-in-water-and-fire-isolated-on-black-background.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img src="assets\images\DealerBust.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img src="assets\images\FH_Gaming_Main-new.jpg" alt="Third slide">
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="icon-prev" 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="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</section>
<body>
</body>
</html>
答案 0 :(得分:0)
您需要将HTML放在<body>
标记内,以便正确呈现。
<body>
<nav>
</nav>
<section id="carousel">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<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>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img src="assets\images\2736779-casino-roulette-in-water-and-fire-isolated-on-black-background.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img src="assets\images\DealerBust.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img src="assets\images\FH_Gaming_Main-new.jpg" alt="Third slide">
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="icon-prev" 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="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</section>
</body>
</html>
答案 1 :(得分:0)
更改课程&#34; carousel-item&#34;到&#34;项目&#34;。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Carousel-testing!</title>
<link rel="stylesheet" href="assets\css\bootstrap.css">
<link rel="stylesheet" href="assets\css\bootstrap-theme.css">
<link rel="stylesheet" href="assets\css\app.css">
<link rel="stylesheet" href="assets\css\animate.css">
<script type="text/javascript" src="assets\js\jquery.js"></script>
<script type="text/javascript" src="assets\js\bootstrap.js"></script>
<script type="text/javascript" src="assets\js\app.js"></script>
</head>
<nav>
</nav>
<section id="carousel">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<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>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="assets\images\2736779-casino-roulette-in-water-and-fire-isolated-on-black-background.jpg" alt="First slide">
</div>
<div class="item">
<img src="assets\images\DealerBust.jpg" alt="Second slide">
</div>
<div class="item">
<img src="assets\images\FH_Gaming_Main-new.jpg" alt="Third slide">
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="icon-prev" 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="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</section>