Before and After Image Slider
How do I make an before and after image slider?
Forked from ace's Pen Before and after image slider.. What is a before and after image slider? How do you make a before and after image slider? This script and codes were developed by Luke Watts on 14 August 2022, Sunday.
Before and After Image Slider - Script Codes HTML Codes
<!DOCTYPE html>
<html class="ace">
<head> <meta charset="UTF-8"> <title>Before and After Image Slider</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"> <link rel='stylesheet prefetch' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.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! */ .lw-before-after-slider { position: relative; margin: 60px; width: 640px; height: 400px;
}
.lw-before-after-slider > * { position: absolute;
}
.lw-before { overflow: hidden;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <section class="lw-before-after-slider"> <figure class="lw-after"> <img src="https://d3e54v103j8qbb.cloudfront.net/gen/img/marketing/code-slider-design.png" width="640" height="400" alt="after" /> </figure> <figure class="lw-before"> <img src="https://d3e54v103j8qbb.cloudfront.net/gen/img/marketing/code-slider-code.png" width="640" height="400" alt="before" /> </figure>
</section> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Before and After Image Slider - Script Codes CSS Codes
.lw-before-after-slider { position: relative; margin: 60px; width: 640px; height: 400px;
}
.lw-before-after-slider > * { position: absolute;
}
.lw-before { overflow: hidden;
}
Before and After Image Slider - Script Codes JS Codes
var $before = $('.lw-before'), imgWidth = $('.lw-before img').width(), initSplit = Math.round(imgWidth/2); $before.width(initSplit); $('.lw-before-after-slider').mousemove(function(e){ var offX = (e.offsetX || e.clientX - $before.offset().left); $before.width(offX); }); $('.lw-before-after-slider').mouseleave(function(e){ $before.stop().animate({ width: initSplit },750, "easeOutBack") });
Developer | Luke Watts |
Username | lukewatts |
Uploaded | August 14, 2022 |
Rating | 3 |
Size | 2,747 Kb |
Views | 46,552 |
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 |
Affinity4 SVG Logo Animation | 2,729 Kb |
SmartQRTravel Login Form | 4,102 Kb |
CSS Dark Neon LED Volume Dial | 3,893 Kb |
Form Inputs | 3,504 Kb |
Turnable LED Dial | 5,472 Kb |
Style System | 4,691 Kb |
CSS Drop Shadows with Global Illumination | 2,559 Kb |
Footer Concept 02 | 10,469 Kb |
HUD Animation Test | 4,015 Kb |
Sass Get Function | 2,155 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 |
Getting Started | Viblast | 1,500 Kb |
Owl Carousel - jumpTo | OwlFonk | 2,553 Kb |
Awesome Full Page Menu Nav | Ey_intuitive | 4,194 Kb |
A Pen by Jess | Jessamyne | 5,100 Kb |
Page Transitions in Backbone | Mikefowler | 3,691 Kb |
Testing Portfolio Page | Sideshowli | 3,395 Kb |
Pericles mi loro... | Judag | 4,125 Kb |
We Simplify animation | Meodai | 48,169 Kb |
Virtual vinyl | Davidpanik | 3,474 Kb |
Pure CSS candle light animation by One element | Ksksoft | 2,193 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!