Floating Product image
How do I make an floating product image?
What is a floating product image? How do you make a floating product image? This script and codes were developed by Lahvjal on 24 August 2022, Wednesday.
Floating Product image - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>floating Product image</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="space"></div>
<div class="row"> <div class="product-img-box"></div> <div class="desc" id="desc"></div> <div class="clear"></div>
</div>
<div class="space"></div>
<div class="space"></div>
<div class="space"></div>
<div class="space"></div> <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Floating Product image - Script Codes CSS Codes
body { margin: 0; padding: 0; display: flex; align-items: center; flex-direction: column;
}
.row { width: 1200px; height: auto; background-color: #ccc; display: flex; position: relative;
}
.product-img-box { height: 300px; width: 50%; background-color: blue; margin-top: 0px;
}
#desc { height: 1500px; width: 50%; background-color: red;
}
.clear { clear: both;
}
.space { width: 1200px; height: 200px; background-color: orange;
}
Floating Product image - Script Codes JS Codes
jQuery(window).on('scroll', function () { var scrollTopz = jQuery(window).scrollTop(), elementOffsetz = jQuery('.row').offset().top, element2Off = jQuery('#desc').offset().top, productH = jQuery('.product-img-box').height(), descH = jQuery('#desc').height(), descBottom = (descH - productH), distancez = (element2Off - scrollTopz); if(distancez <= 0 && distancez >= (-descBottom - 1)) { jQuery('.product-img-box, #product-uses-outer').css({ 'margin-top': scrollTopz - element2Off }) } else if(distancez <= -descBottom) { jQuery('.product-img-box, #product-uses-outer').css({ 'margin-top': descBottom }) } else { jQuery('.product-img-box, #product-uses-outer').css({ 'margin-top': '0px' }) } console.log(scrollTopz, distancez, descBottom, (distancez <= -descBottom), elementOffsetz, element2Off);
})
Developer | Lahvjal |
Username | lahvjal |
Uploaded | August 24, 2022 |
Rating | 3 |
Size | 2,443 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 |
RMO live StyleGuide | 13,045 Kb |
Buttons - RMO | 3,954 Kb |
RMO Live Style Guide | 22,749 Kb |
Run script before page load | 1,453 Kb |
PNT Page | 4,697 Kb |
Blog-article-blocks | 1,630 Kb |
Paragraphs - RMO | 2,099 Kb |
24 Hour Countdown Clock Loop | 2,215 Kb |
Rotate wheel | 1,583 Kb |
Recycle Search - RMO | 1,483 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 |
Animate a paper plane along an SVG path, looking ahead | PotatoDie | 3,734 Kb |
Flower expansion | Sreucherand | 3,425 Kb |
Awesome Full Page Menu Nav | Ey_intuitive | 4,194 Kb |
Intake Form Page 2 | Ijantje | 4,983 Kb |
Sticky menu on scroll | Senff | 2,869 Kb |
Apex Calculator | Michaelwnelson | 2,370 Kb |
Slide out Menu | Rbiggs | 4,936 Kb |
Touch Carousel - last, no gaps. | Berkin | 4,332 Kb |
Brian The CSS Bee | Jonitrythall | 3,922 Kb |
Review test | Otro_user_gil | 4,054 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!