• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

    html+css实现图片扫描仪特效

    发布者: 雪落无声 | 发布时间: 2025-6-16 12:25| 查看数: 72| 评论数: 0|帖子模式

    本文主要介绍了html css 图片扫描仪,分享给大家,具体如下:
    效果:
    这样,有抖动的:

    无抖动的:

    实现:

    1.定义一个盒子:
    1. <body>
    2.     <div class="tu"></div>
    3. </body>
    复制代码
    2.基本样式,长宽背景图等等~
    1. .tu{
    2.             width: 500px;
    3.             height: 300px;
    4.             background-image: url(8.jpg);
    5.             background-size: 100% auto;
    6.             background-repeat: no-repeat;
    7.             position: relative;
    8.             overflow: hidden;
    9.             cursor: pointer;
    10.         }
    复制代码
    cursor: pointer;鼠标经过盒子样式为小手
    3.用伪类元素做扫描线,基本样式:
    1. .tu::after{
    2.             content: '';
    3.             position: absolute;
    4.             top: 0;
    5.             left: 0;
    6.             width: 500px;
    7.             height: 35px;
    8.             background-image: url(8.jpg);
    9.             background-size: 100% auto;
    10.             background-repeat: no-repeat;
    11.             filter: sepia(100%);
    12.             opacity: 0;
    13.            
    14.         }
    复制代码
    filter: sepia(100%); 图片发黄。
    filter: invert(100%); 像X光底片。
    4.实现扫描:
    1. .tu:hover::after{
    2.             opacity: 1;
    3.             animation: move 1.8s linear infinite;
    4.         }
    5.         @keyframes move{
    6.             0%{
    7.                 top: 0;
    8.                 background-position: 6px 0px;
    9.             }
    10.             20%{
    11.                 top: 60px;
    12.                 background-position: -6px -60px;
    13.             }
    14.             40%{
    15.                 top: 120px;
    16.                 background-position: 6px -120px;
    17.             }
    18.             60%{
    19.                 top: 180px;
    20.                 background-position: -6px -180px;
    21.             }
    22.             80%{
    23.                 top: 240px;
    24.                 background-position: 6px -240px;
    25.             }
    26.             100%{
    27.                 top: 300px;
    28.                 background-position: -6px -300px;
    29.             }
    30.         }
    复制代码
    让background-position的y轴位移刚好等于top的距离,然后x轴为0的话就不抖,有数值就会抖动。
    完整代码:
    1. <!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>        *{            margin: 0;            padding: 0;            box-sizing: border-box;        }        body{            height: 100vh;            display: flex;            justify-content: center;            align-items: center;            background-color: rgb(0, 0, 0);        }        .tu{
    2.             width: 500px;
    3.             height: 300px;
    4.             background-image: url(8.jpg);
    5.             background-size: 100% auto;
    6.             background-repeat: no-repeat;
    7.             position: relative;
    8.             overflow: hidden;
    9.             cursor: pointer;
    10.         }        .tu::after{            content: '';            position: absolute;            top: 0;            left: 0;            width: 500px;            height: 20px;            background-image: url(8.jpg);            background-size: 100% auto;            background-repeat: no-repeat;            filter: invert(100%);             opacity: 0;                   }        .tu:hover::after{
    11.             opacity: 1;
    12.             animation: move 1.8s linear infinite;
    13.         }
    14.         @keyframes move{
    15.             0%{
    16.                 top: 0;
    17.                 background-position: 6px 0px;
    18.             }
    19.             20%{
    20.                 top: 60px;
    21.                 background-position: -6px -60px;
    22.             }
    23.             40%{
    24.                 top: 120px;
    25.                 background-position: 6px -120px;
    26.             }
    27.             60%{
    28.                 top: 180px;
    29.                 background-position: -6px -180px;
    30.             }
    31.             80%{
    32.                 top: 240px;
    33.                 background-position: 6px -240px;
    34.             }
    35.             100%{
    36.                 top: 300px;
    37.                 background-position: -6px -300px;
    38.             }
    39.         }    </style></head><body>
    40.     <div class="tu"></div>
    41. </body></html>
    复制代码
    总结:

    这是网上看到一外国博主的创意,然后自己也弄了一个,虽然效果是比较简单的,但也是挺好玩的~
    到此这篇关于html+css实现图片扫描仪特效 的文章就介绍到这了,更多相关html+css图片扫描仪 内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

    来源:https://www.jb51.net/html5/767898.html
    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    ×

    最新评论

    浏览过的版块

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表