html+css实现图片扫描仪特效
建站知识 2021-07-02 23:00www.168986.cn长沙网站建设
本文主要介绍了html css 图片扫描仪,分享给大家,具体如下
效果
这样,有抖动的
无抖动的
实现
1.定义一个盒子
<body> <div class="tu"></div> </body>
2.基本样式,长宽背景图等等~
.tu{ width: 500px; height: 300px; background-image: url(8.jpg); background-size: 100% auto; background-repeat: no-repeat; position: relative; overflow: hidden; cursor: pointer; }
cursor: pointer;鼠标经过盒子样式为小手
3.用伪类元素做扫描线,基本样式
.tu::after{ content: ''; position: absolute; : 0; left: 0; width: 500px; height: 35px; background-image: url(8.jpg); background-size: 100% auto; background-repeat: no-repeat; filter: sepia(100%); opacity: 0; }
filter: sepia(100%); 图片发黄。
filter: invert(100%); 像X光底片。
4.实现扫描
.tu:hover::after{ opacity: 1; animation: move 1.8s linear infinite; } @keyframes move{ 0%{ : 0; background-position: 6px 0px; } 20%{ : 60px; background-position: -6px -60px; } 40%{ : 120px; background-position: 6px -120px; } 60%{ : 180px; background-position: -6px -180px; } 80%{ : 240px; background-position: 6px -240px; } 100%{ : 300px; background-position: -6px -300px; } }
让background-position的y轴位移刚好等于的距离,然后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> { 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{ width: 500px; height: 300px; background-image: url(8.jpg); background-size: 100% auto; background-repeat: no-repeat; position: relative; overflow: hidden; cursor: pointer; } .tu::after{ content: ''; position: absolute; : 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{ opacity: 1; animation: move 1.8s linear infinite; } @keyframes move{ 0%{ : 0; background-position: 6px 0px; } 20%{ : 60px; background-position: -6px -60px; } 40%{ : 120px; background-position: 6px -120px; } 60%{ : 180px; background-position: -6px -180px; } 80%{ : 240px; background-position: 6px -240px; } 100%{ : 300px; background-position: -6px -300px; } } </style> </head> <body> <div class="tu"></div> </body> </html>
这是网上看到一外国博主的创意,然后自己也弄了一个,虽然效果是比较简单的,但也是挺好玩的~
到此这篇关于html+css实现图片扫描仪特效 的文章就介绍到这了,更多相关html+css图片扫描仪 内容请搜索狼蚁SEO以前的文章或继续浏览狼蚁网站SEO优化的相关文章,希望大家以后多多支持狼蚁SEO!
长沙网站设计
- 如何自己建一个网站 自己想建个网站,怎么建
- 如何制作网站免费建站 创建网站免费注册
- html简单网页代码 html简单网页代码超链接
- dreamweaver网页制作 dreamweaver网页制作模板
- 上海网站建设 上海网站建设制作微信
- 如何制作网站和网页 如何制作一个网页
- html网页制作代码大全 端午节html网页制作代码大
- app开发公司 app开发公司前十名
- html网页制作 html网页制作文字居中
- app制作一个需要多少钱 请人制作一个app多少钱
- 成都网站制作 成都网站制作维护
- 百度建一个网站多少钱 百度做个公司网站要多少
- html+css网页制作成品 web网页制作成品css+javascrip
- html网页制作案例 html网页设计案例
- html+css网页制作成品 web网页制作成品css+javascrip
- 个人网站模板 个人网站模板HTML