Js+CSS实现影像的卷帘效果

作者: 知足常乐晨 | 来源:发表于2019-07-01 15:13 被阅读14次

常见于GIS行业,下面列子中使用了两张图片的卷帘对比效果,效果图如下:


image.png
<html><head>
    <title>前后对比</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language" content="zh-CN">
    <link href="css/roll.css" type="text/css" rel="stylesheet">
    <style type="text/css">
        

    
.beforeafter{
    width: 940px;
    height: 529px;
}
#after{
    position: absolute;
    top: 0px;
    left: 0px;
    background-image: url(./2.jpg);
    width: 940px;
    height: 529px;
    background-repeat: no-repeat;
}
#before{
    position: absolute;
    top: 0px;
    left: 0px;
    border-right: 3px solid #f00;
    background-image: url(./1.jpg);
    width: 433px;
    height: 529px;
    background-repeat: no-repeat;
    max-width: 940px;
}
</style>
    <script src="./jquery-1.12.3.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        function RollImage(evt){
           var x=evt.pageX;
          $("#before").css("width",x+"px");
        }
    </script>
</head>
<body>
<div class="beforeafter" onmousemove="RollImage(event)">
    <div id="after"></div>
    <div id="before"> </div>
</div>
</body>
</html>

相关文章

网友评论

    本文标题:Js+CSS实现影像的卷帘效果

    本文链接:https://www.haomeiwen.com/subject/ktmgcctx.html