Visual effects Demo
How do I make an visual effects demo?
Covers image based on width, select the effect to remain on mouseout, or to bounce back to the middle using css transforms. . What is a visual effects demo? How do you make a visual effects demo? This script and codes were developed by Hans Engebretsen on 09 August 2022, Tuesday.
Visual effects Demo - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Visual effects Demo</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! */ @import url(http://fonts.googleapis.com/css?family=Ubuntu+Mono);
html { font-family: 'Ubuntu Mono' arial, sans-serif; background: #d1d1de; text-align: center; color: white;
}
.page-wrap { margin: 0 auto; width: 600px; max-width: 100%; padding-top: 25px;
}
.toggle-function { text-align: center; width: 100%; display: block; margin: 10px 0 25px 0;
}
.btn { display: inline-block; padding: .5em; text-align: center; border: 2px solid white; cursor: pointer; background-color: white; color: #d1d1de;
}
.btn:nth-child(2) { border-left: none;
}
.btn:nth-child(1) { background-color: transparent; color: white;
}
.stay .btn { background-color: #d1d1de; color: white;
}
.stay .btn:nth-child(1) { background-color: white; color: #d1d1de;
}
.vfx-image-wrap { position: relative; display: inline-block; margin: 0 auto; width: 600px; min-height: 273px; margin-bottom: 40px; cursor: ew-resize;
}
.before-image { position: absolute; top: 0; left: 0; z-index: 1; width: 50%; overflow: hidden;
}
.after-image { position: absolute; top: 0; left: 0; z-index: 0;
}
.divider-bar { position: absolute; width: 2px; left: 50%; top: -10px; bottom: -15px; background: white; height: 100%; display: block; z-index: 2; box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.4);
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="page-wrap"> <span>When mouse leaves divider</span> <span class="toggle-function"> <span class="stay btn">Stays</span><span class="bounce-back btn">Bounces Back</span> </span> <div class="vfx-image-wrap"> <div class="before-image"> <img src="https://raw.githubusercontent.com/HansEngebretsen/my-image-host/master/VFX-before.jpg" alt="" /> </div> <div class="after-image"> <img src="https://raw.githubusercontent.com/HansEngebretsen/my-image-host/master/VFX-after.jpg" alt="" /> </div> <div class="divider-bar"></div> </div> <div class="vfx-image-wrap"> <div class="before-image"> <img src="https://raw.githubusercontent.com/HansEngebretsen/my-image-host/master/VFX3-before.jpg" alt="" /> </div> <div class="after-image"> <img src="https://raw.githubusercontent.com/HansEngebretsen/my-image-host/master/VFX3-after.jpg" alt="" /> </div> <div class="divider-bar"></div> </div> <div class="vfx-image-wrap"> <div class="before-image"> <img src="https://raw.githubusercontent.com/HansEngebretsen/my-image-host/master/VFX2-before.jpg" alt="" /> </div> <div class="after-image"> <img src="https://raw.githubusercontent.com/HansEngebretsen/my-image-host/master/VFX2-after.jpg" alt="" /> </div> <div class="divider-bar"></div> </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>
Visual effects Demo - Script Codes CSS Codes
@import url(http://fonts.googleapis.com/css?family=Ubuntu+Mono);
html { font-family: 'Ubuntu Mono' arial, sans-serif; background: #d1d1de; text-align: center; color: white;
}
.page-wrap { margin: 0 auto; width: 600px; max-width: 100%; padding-top: 25px;
}
.toggle-function { text-align: center; width: 100%; display: block; margin: 10px 0 25px 0;
}
.btn { display: inline-block; padding: .5em; text-align: center; border: 2px solid white; cursor: pointer; background-color: white; color: #d1d1de;
}
.btn:nth-child(2) { border-left: none;
}
.btn:nth-child(1) { background-color: transparent; color: white;
}
.stay .btn { background-color: #d1d1de; color: white;
}
.stay .btn:nth-child(1) { background-color: white; color: #d1d1de;
}
.vfx-image-wrap { position: relative; display: inline-block; margin: 0 auto; width: 600px; min-height: 273px; margin-bottom: 40px; cursor: ew-resize;
}
.before-image { position: absolute; top: 0; left: 0; z-index: 1; width: 50%; overflow: hidden;
}
.after-image { position: absolute; top: 0; left: 0; z-index: 0;
}
.divider-bar { position: absolute; width: 2px; left: 50%; top: -10px; bottom: -15px; background: white; height: 100%; display: block; z-index: 2; box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.4);
}
Visual effects Demo - Script Codes JS Codes
// Some notes taken from http://codepen.io/Fellini85/pen/oaDBh
$(function () { var imageWrap = $('.vfx-image-wrap'), topImage = $(this).find('.before-image'), divider = $(this).find('.divider-bar'), stayBounce = $('.toggle-function'); imageWrap.on("mousemove", function (e) { // Gotta localize top image and divider so it only applies to this var offsets = $(this).offset(), fullWidth = $(this).width(), mouseX = e.pageX - offsets.left, topImage = $(this).find('.before-image'), divider = $(this).find('.divider-bar'); if (mouseX < 0) { mouseX = 0; } else if (mouseX > fullWidth) { mouseX = fullWidth } $(this).addClass('special'); divider.css({ left: mouseX, transition: 'none' }); topImage.css({ width: mouseX, transition: 'none' }); }); stayBounce.click(function(){ $(this).toggleClass('stay'); }); imageWrap.on("mouseleave", function () { if (!stayBounce.hasClass('stay')) { divider.css({ left: '50%', transition: 'all .3s' }); topImage.css({ width: '50%', transition: 'all .3s' }); } });
});
Developer | Hans Engebretsen |
Username | hans |
Uploaded | August 09, 2022 |
Rating | 4.5 |
Size | 4,184 Kb |
Views | 36,432 |
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 |
Background-filter toggle | 38,215 Kb |
Product -Thumb Hover | 4,960 Kb |
Pure CSS FitText | 3,357 Kb |
Whisky Friday | 5,677 Kb |
The World Wide Web | 7,352 Kb |
Nav Menu Hover | 4,538 Kb |
Candy Text Typographic Fun | 4,103 Kb |
Typographic Fun | 3,844 Kb |
Beautiful gradients, Expanding collums | 4,088 Kb |
Timeline Sign Load Transition | 3,926 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 |
A Pen by lizz | Lizz | 10,068 Kb |
LBCA - Mail canvas | Emnbdx | 3,856 Kb |
Draggables in pure angular | Rlo206 | 5,167 Kb |
Drag n Drop | Martin42 | 2,594 Kb |
Playing with FlexBox | _Billy_Brown | 3,162 Kb |
Electric worm | Jeffibacache | 2,377 Kb |
Animated Logo | Shakdaniel | 2,672 Kb |
Simple star rating using js and data-uri | TheEnd | 5,795 Kb |
Simple checkbox style | Vncnz | 2,628 Kb |
Responsive Table-less Shopping Cart | Alex_rodrigues | 6,637 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!