Pure CSS for carousel mapping

Source: Internet
Author: User

The implementation principle of the Carousel diagram is actually relatively simple.

As an example,

<div  class= "main" ><div class= "Div-main" ></div></div>

The width of main is 100px

The width of the div-main is 500px

We use JS control Div-main to the left or to the right to move, so that the implementation of the Carousel, simple

Okay, let's start with a CSS3 API.

Animation: myfirst 5s linear 2s infinite alternate ;

Myfirst: Animation name

5s: How often do animations finish

Linear: What curve does the animation perform

2s: How long does animation delay execute

Infinite: This parameter is the animation has been looping, can write numbers also line

Alternate: Only animations are performed upside down

First introduced here, complete usage can refer to: CSS3 Animation API Reference

The following code:

<! DOCTYPE html>
   #frame {position:absolute;width:302px;height:200px;overflow:hidden;border-radius:5px}    #dis {position: absolute;left:-50px;top:-10px;opacity:.5}    #dis li{display:inline-block;width:200px;height:20px;margin:0 50px;float:left;text-align:center;color: #fff; border-radius:10px;background: #000}    #photos. img{float:left; WIDTH:300PX;HEIGHT:200PX;BACKGROUND-COLOR:RED;BORDER-LEFT:1PX solid blue;}    #photos {  position:absolute;z-index:9;  Width:calc (301PX * 4);/*---Modify the number of pictures, you need to modify the following animation parameters */  }    . play{animation:ma 5s ease-out infinite Alternate;}    @keyframes Ma {        0%,25% {        margin-left:0px;       }        30%,50% {       margin-left: -300px;    }        55%,75% {       margin-left: -600px;    }        80%,100% {       margin-left: -900px;    }    }

What code is not as much as a running demo online

Pure CSS for carousel mapping

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.