audrey audrey - 1 month ago 6
CSS Question

bootstrap carousel not working, but turning into background images

Im pretty much a newbie to coding and ive been trying to do a slider on bootstrap for a whle but it's not really working as it becomes something like a background

heres my HTML

<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class= "container">
<div class="navbar-header">
<a class="navbar-brand" href"#">
<img src="img/logowine.png" alt="winelogo">
</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mynavbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="mynavbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">
<a href="#">Home</a>
</li>
<li>
<a href="#about">About </a>
</li>
<li>
<a href="#product">Products</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
</div>
<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>
</ol>
<div class="carousel-inner" role="listbox">
<div clas="item active">
<img src="img/carousel1.jpg" alt="portdicksonrj" class="img-responsive">
</div>
<div clas="item">
<img src="img/carousel2.jpg" alt="portdicksonrjice" class="img-responsive">
</div>
<div clas="item">
<img src="img/carousel3.jpg" alt="portdicksonrjlemon" class="img-responsive">
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$("#carousel").carousel();
</script>




</body>


it comes out like
this
and
this

Answer

You miss spelling of your class word just change your HTML clas to class Solve your problem .

NB: Also Please ensure it you was add Bootstrap CSS

NB: I Edit Your Question so now it's working well.

Look at my Bootstrap Carousel.

 .carousel-inner > .item > img,
  .carousel-inner > .item > a > img {
      width: 70%;
      margin: auto;
}

.item img {
  height: 400px !important
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<div class="container">
  <br>
  <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <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>
<li data-target="#myCarousel" data-slide-to="4"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
      <div class="item active">
        <img src="https://upload.wikimedia.org/wikipedia/commons/4/47/Goole.jpg" alt="Chania 1" width="460" height="345">
      </div>

      <div class="item">
        <img src="https://peterwardhomes.files.wordpress.com/2014/12/goole-area-shot_005.jpg" alt="Chania" width="460" height="345">
      </div>

      <div class="item">
        <img src="http://www.telegraph.co.uk/content/dam/Travel/Destinations/Europe/France/Nice/Nice-nightlife-coastline-xlarge.jpg" alt="Flower 1" width="460" height="345">
      </div>

      <div class="item">
        <img src="http://i.telegraph.co.uk/multimedia/archive/01858/nice3_1858695b.jpg" alt="Flower" width="460" height="345">
      </div>

      <div class="item">
        <img src="http://eastriding.limehouse.co.uk/events/21318/images/highresRGB/2376387_0_1.jpg" alt="Flower" width="460" height="345">
      </div>
    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</div>

Comments