JS Automatic gradient Carousel

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.