javascript - Fade images after delay -


i'm trying switch images in div every few seconds
current code works, there 2 things want change , need that:

  1. the div resizes current image displaying in it, want use size of bigger image
  2. i want fade between images instead of switching

thanks reading, hope can me.

this got far:

var imgindex = 0;  setinterval(function() {    images[imgindex].style.display = "none";    imgindex++;    if (imgindex >= images.length) {      imgindex = 0;    }    images[imgindex].style.display = "block";  }, 5000);
.imagedisplay {    display: inline-block;    width: 100%;    background-color: white;    color: black;    border-radius: 5%;    margin: 2px;    padding: 1px;    opacity: 0.5;    transition-duration: 0.5s;  }    .imagedisplay:hover {    opacity: 1;  }    .image {    width: 99%;    height: auto;    margin: 1px;    padding: 1px;    border-radius: 5%;    cursor: pointer;    display: none;  }
<div class="imagedisplay">    <p>description</p>    <img class="image"></img>    <img class="image"></img>  </div>

firstly set div equal size of large image , use:

object-fit: cover; object-position:center; 

as switching use:

transition: opacity .3s linear; 

read here on how implement transitions. suggestion stacking them , fading them in 1 one every few seconds.

https://www.w3schools.com/css/css3_transitions.asp

http://css3.bradshawenterprises.com/cfimg/


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -