Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use html+css to realize the Special effects of Image Scanner

Shulou Source: shulou.com Published: 2022-06-01 13:05:05 09月25日 Update

This article will explain in detail how to use html+css to achieve image scanner special effects. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Achieve:

1. Define a box:

two。 Basic style, length and width background and so on.

.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; mouse over box style is small hand

3. Use pseudo-class elements as scan lines, basic styles:

.tu:: after {content:'; position: absolute; top: 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%); the picture is yellow.

Filter: invert (100%); like X-ray film.

4. Implement scanning:

.tu: hover::after {opacity: 1; animation: move 1.8s linear infinite;} @ keyframes move {0% {top: 0; background-position: 6px 0px;} 20% {top: 60px; background-position:-6px-60px } 40% {top: 120px; background-position: 6px-120px;} 60% {top: 180px; background-position:-6px-180px;} 80% {top: 240px Background-position: 6px-240px;} 100% {top: 300px; background-position:-6px-300px;}}

Let the y-axis displacement of background-position be exactly equal to the distance of top, and then if the x-axis is 0, it will not shake, and if there is a value, it will wobble.

Complete code:

Document * {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; top: 0; left: 0; width: 500px; height: 20px; background-image: url (8.jpg); background-size: 100% auto; background-repeat: no-repeat Filter: invert; opacity: 0;} .tu: hover::after {opacity: 1; animation: move 1.8s linear infinite;} @ keyframes move {0% {top: 0; background-position: 6px 0px } 20% {top: 60px; background-position:-6px-60px;} 40% {top: 120px; background-position: 6px-120px;} 60% {top: 180px Background-position:-6px-180px;} 80% {top: 240px; background-position: 6px-240px;} 100% {top: 300px; background-position:-6px-300px }} this is the end of the article on "how to use html+css to achieve special effects for picture scanners". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Pictures styles articles scanners special effects more boxes good practical code elements content small hands negatives scan lines numeric values articles knowledge background mouse Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Huawei MySQL Xiaomi