CSS optical illusion
How do I make an css optical illusion?
Booth blocks have the same speed and position at all times.Click toggle to change the background and see for yourself.. What is a css optical illusion? How do you make a css optical illusion? This script and codes were developed by Ludvig Lindblom on 25 July 2022, Monday.
CSS optical illusion - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS optical illusion</title> <script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html { background: #999; padding: 0;
}
body { margin: 0; padding: 0;
}
a { font-family: sans-serif; font-size: 20px; font-weight: bold; line-height: 1; text-decoration: none; display: inline-block; padding: 10px; background: #000; color: #fff;
}
a:hover, a:focus { text-decoration: underline;
}
#track { background-color: #999; background-image: linear-gradient(90deg, #000 0%, #000 50%, #fff 50%, #fff 100%); background-size: 50px 50px; border: 1px solid #000; width: 675px; height: 225px; position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto; padding: 0;
}
#track.proof { background-image: none;
}
.block { width: 100px; height: 40px; position: absolute; left: 0; animation: illusion 9s linear infinite alternate;
}
.block.light { background: #fff; top: 10px;
}
.block.dark { background: #000; bottom: 10px;
}
@keyframes illusion { from { left: 0; } to { left: calc(100% - 100px); }
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <a href='#'>Toggle</a>
<div id='track'> <div class='block light'></div> <div class='block dark'></div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
CSS optical illusion - Script Codes CSS Codes
html { background: #999; padding: 0;
}
body { margin: 0; padding: 0;
}
a { font-family: sans-serif; font-size: 20px; font-weight: bold; line-height: 1; text-decoration: none; display: inline-block; padding: 10px; background: #000; color: #fff;
}
a:hover, a:focus { text-decoration: underline;
}
#track { background-color: #999; background-image: linear-gradient(90deg, #000 0%, #000 50%, #fff 50%, #fff 100%); background-size: 50px 50px; border: 1px solid #000; width: 675px; height: 225px; position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto; padding: 0;
}
#track.proof { background-image: none;
}
.block { width: 100px; height: 40px; position: absolute; left: 0; animation: illusion 9s linear infinite alternate;
}
.block.light { background: #fff; top: 10px;
}
.block.dark { background: #000; bottom: 10px;
}
@keyframes illusion { from { left: 0; } to { left: calc(100% - 100px); }
}
CSS optical illusion - Script Codes JS Codes
$("body").on("click", "a", function(e) { e.preventDefault(); $("#track").toggleClass("proof");
});
Developer | Ludvig Lindblom |
Username | ludviglindblom |
Uploaded | July 25, 2022 |
Rating | 4 |
Size | 3,443 Kb |
Views | 99,176 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Rotating timer | 2,640 Kb |
Css arrows and pies | 2,584 Kb |
Circle star | 2,690 Kb |
The Ultimate Flexbox Cheat Sheet | 7,954 Kb |
Canvas pie chart with CSS bar chart fallback | 4,014 Kb |
Fullscreen API | 2,979 Kb |
Optical illusion - Motion Binding | 3,875 Kb |
Canvas box-shadow pixel art generator | 3,678 Kb |
Starburst | 3,581 Kb |
Rainy days | 227,548 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Flying Bee | Pwsm50 | 3,711 Kb |
A Pen by Gregory Potdevin | GregoryPotdevin | 1,713 Kb |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
The CodePen Logo | Kindofone | 4,259 Kb |
Hard-Stop Gradients | Mackdoyle | 2,288 Kb |
Speech bubbles | Something | 1,547 Kb |
Falling Down the Rabbit Hole | Rachelnabors | 4,578 Kb |
Day 11 - Calendar Card | Arnellebalane | 6,984 Kb |
Personal Website Redesign v2.0 | DevItWithDavid | 5,168 Kb |
SCSS Simple Animated Drop-In | Danwarfel | 2,175 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!