简体   繁体   中英

why is only one of my image showing for my html slideshow?

I'm trying to make an automatic image slideshow using only html and css. I finally found a simple tutorial on how to make one except i slightly changed the code to make my images move left instead. Right now, the problem I'm facing is that only 1 out of my 2 images is showing up. Why is this?

 .maincontainer{ position: relative; width:100%; height:500px; overflow:hidden; }.maincontainer > img{ position:absolute; float: left; animation: sliding 20s infinite; left:0; width: 100%; height:auto; } @keyframes sliding{ 0%{left:0px} 10%{left:0px} 20%{left:-700x} 30%{left:-700px} 40%{left:-1200px} 50%{left:-1200px} 60%{left:-1500px} 70%{left:-1500px} 80%{left:-2400px} 90%{left:-2400px} 100%{left:0px} }.sliding {width:100%; height:0px; padding-bottom: 50%; overflow:hidden; position:relative; }
 <div class="maincontainer"> <img src="pictures/stove.jpg" alt="slide1"> <img src="pictures/hp.jpeg" alt="slide2"> </div>

I faced a similar kind of problem, so I think this code should work according to your problem:

<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>
    </ol>

    <div class="carousel-inner" style="border-radius: 5px;">

      <div class="item active">
        <a href="#" target="_blank"><img src="Images/oneplus-7-pro-hero-image.jpg" alt="" style="width:100%; height: 375px;" class="img-responsive"></a>

      </div>

      <div class="item">
        <a href="#" target="_blank"><img src="Images/huawei-p30-singapore-prices.png" alt="" style="width:100%; height: 375px;" class="img-responsive"></a>

      </div>

    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev" style="background: transparent; width: 25px;">
      <span class="glyphicon glyphicon-chevron-left"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next" style="background: transparent; width: 25px;">
      <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM