The gradient is mainly implemented by CSS3 animations.
Just add the Transtion animation time to the CSS plus JS settings specify the image transparency display and disappear to achieve the gradient process.
:
Html:
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <Linkrel= "stylesheet"type= "Text/css"href= "Css/style3.css" /> <Scripttype= "Text/javascript"language= "JavaScript"src= "Js/script3.js"></Script> </Head> <Body> <DivID= "box"> <ul> <Li></Li> <Li></Li> <Li></Li> <Li></Li> </ul> </Div> </Body></HTML>
Css:
*{margin:0;padding:0;}#box{width:300px;Height:165px;Border:1px Black Solid;margin:10px Auto;}#box ul{List-style:None;position:relative;}#box ul Li{width:300px;Height:165px;position:Absolute;transition:all 1s;Opacity:0;}#box ul li:nth-of-type (1){background:URL (.. /img/img1.jpg);background-size:100%;}#box ul li:nth-of-type (2){background:URL (.. /img/img2.jpg);background-size:100%;}#box ul li:nth-of-type (3){background:URL (.. /img/img3.jpg);background-size:100%;}#box ul Li:nth-of-type (4){background:URL (.. /img/img4.jpg);background-size:100%;}
Js:
onload =function(){ varLi = document.getElementById (' box '). getElementsByTagName (' Li ')); varindex = 0; Goto (); functionGoto () { for(vari=0;i<li.length;i++) {li[i].style.opacity = 0;} if(index = = li.length) Index = 0; Li[index++].style.opacity = 1; } varTimer = setinterval (goto,3000); }
PS: only to help you here, buttons or something ....
JS Automatic gradient Carousel