温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何使用html+css实现图片扫描仪特效

发布时间:2022-02-23 09:50:37 阅读:326 作者:小新 栏目:开发技术
前端开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这篇文章将为大家详细讲解有关如何使用html+css实现图片扫描仪特效,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

实现:

1.定义一个盒子:

<body>
    <div class="tu"></div>
</body>

2.基本样式,长宽背景图等等~

.tu{
            width500px;
            height300px;
            background-imageurl(8.jpg);
            background-size100% auto;
            background-repeat: no-repeat;
            position: relative;
            overflow: hidden;
            cursor: pointer;
        }

cursor: pointer;鼠标经过盒子样式为小手

3.用伪类元素做扫描线,基本样式:

 .tu::after{
            content'';
            position: absolute;
            top0;
            left0;
            width500px;
            height35px;
            background-imageurl(8.jpg);
            background-size100% auto;
            background-repeat: no-repeat;
            filtersepia(100%); 
            opacity0;
           
        }

filter: sepia(100%); 图片发黄。
filter: invert(100%); 像X光底片。

4.实现扫描:

.tu:hover::after{
            opacity1;
            animation: move 1.8s linear infinite;
        }
        @keyframes move{
            0%{
                top0;
                background-position6px 0px; 
            }
            20%{
                top60px;
                background-position: -6px -60px; 
            }
            40%{
                top120px;
                background-position6px -120px; 
            }
            60%{
                top180px;
                background-position: -6px -180px; 
            }
            80%{
                top240px;
                background-position6px -240px; 
            }
            100%{
                top300px;
                background-position: -6px -300px; 
            }
        }

让background-position的y轴位移刚好等于top的距离,然后x轴为0的话就不抖,有数值就会抖动。

完整代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin0;
            padding0;
            box-sizing: border-box;
        }
        body{
            height100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-colorrgb(000);
        }
        .tu{
            width500px;
            height300px;
            background-imageurl(8.jpg);
            background-size100% auto;
            background-repeat: no-repeat;
            position: relative;
            overflow: hidden;
            cursor: pointer;
        }
        .tu::after{
            content'';
            position: absolute;
            top0;
            left0;
            width500px;
            height20px;
            background-imageurl(8.jpg);
            background-size100% auto;
            background-repeat: no-repeat;
            filterinvert(100%); 
            opacity0;
           
        }
        .tu:hover::after{
            opacity1;
            animation: move 1.8s linear infinite;
        }
        @keyframes move{
            0%{
                top0;
                background-position6px 0px; 
            }
            20%{
                top60px;
                background-position: -6px -60px; 
            }
            40%{
                top120px;
                background-position6px -120px; 
            }
            60%{
                top180px;
                background-position: -6px -180px; 
            }
            80%{
                top240px;
                background-position6px -240px; 
            }
            100%{
                top300px;
                background-position: -6px -300px; 
            }
        }
    </style>
</head>
<body>
    <div class="tu"></div>
</body>
</html>

关于“如何使用html+css实现图片扫描仪特效”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×