我想我什么都没错过。但无法运作。我从https://getbootstrap.com/docs/4.0/components/carousel/获得了这段代码。我刚刚将id值从carouselExampleIndicators更改为myCarousel。我看过类似的问题“ Boostrap传送带无法正常工作”。找不到任何错误。
<!doctype html>
<html lang="en">
<head>
<title>Bright Homepage</title>
<meta charset="utf-8">
<meta name="viewpoint" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="daynightstyle.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#myCarousel').carousel({
interval: 2000,
pause: "false"
});
});
</script>
</head>
<body>
<div id="header">
<h1><a href="index.html">BRIGHT'S HOMEPAGE</a></h1>
<a href="aboutme.html">ABOUT ME</a>
<a href="mycity.html">ABOUT MY CITY</a>
<a href="mypodcast.html">ABOUT MY PODCASTS</a>
<a href="mycampus.html">MY CAMPUS</a>
<a href="myphotos.html">MY PHOTOS</a>
<div id="ch_btn">
<input type="button" value="night" onclick="nightDayHandler(this)">
</div>
</div>
<div class="container-fluid">
<h2>Welcome to My Home</h2>
<h3>This is my home.</h3>
<p>I want that my house should be a place where you feel most comfortable<br />
A Stranger in My Home should be an exciting. Bring more people to my home. Enjoy your time on my Homepage</p>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block w-100" src="images\boise_downtown.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="images\hilltop_town.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="images\koldalen.jpg" alt="Third slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="images\night_fog.jpg" alt="First slide">
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</body></html>
答案 0 :(得分:0)
我添加了以下代码。可以。
<style>
.carousel-item > img {
position: relative;
min-width: 100%;
height: 100%;
}
</style>