JAVASCRIPT+CSS realization of the image roll-curtain effect

Source: Internet
Author: User

Used ArcGIS cheese for arcmap inside of a rolling shutter effect is sure to remember very deep, want to move it to their own webgis system, holding the same idea, I also on this kind of more dazzling shutter effect did a bit of research, Roar, come out, give us a report on the results, first look at a picture:


roller shutter effect

See this effect, you are not the chicken moved a bit, hey, don't worry, listen to my slowly way.


First, the container. Use two div to display two images of different periods. Next, set the two container's style, code:

#after {    position:absolute;    top:0px;    left:0px;    Background-image:url (.. /images/24.jpg);    width:940px;    height:529px;    Background-repeat:no-repeat;} #before {    position:absolute;    top:0px;    left:0px;    border-right:3px solid #f00;    Background-image:url (.. /images/23.jpg);    width:433px;    height:529px;    Background-repeat:no-repeat;    max-width:940px;}
In this way, the picture is displayed on the web.


Next, you implement the swipe effect. To implement the shutter, the main thing is to set the width of the before, how to set it, is to get the location of the mouse, the code is as follows:

        function Rollimage (evt) {            var X=evt.pagex;            Console.log (x);            $ ("#before"). CSS ("width", x+ "px");        }    </script>

In this way, the effect of the shutter is realized. The source code is as follows:

Style.css

. beforeafter{    width:940px;    height:529px;} #after {    position:absolute;    top:0px;    left:0px;    Background-image:url (.. /images/24.jpg);    width:940px;    height:529px;    Background-repeat:no-repeat;} #before {    position:absolute;    top:0px;    left:0px;    border-right:3px solid #f00;    Background-image:url (.. /images/23.jpg);    width:433px;    height:529px;    Background-repeat:no-repeat;    max-width:940px;}

Test.html



Javascript+css to implement an image roll effect

Related Article

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.