Helpful resources
            
           
              Need more help?
             
             
              Check out the Webflow community.
             
            
              Free Webflow templates
             
             
              The best free Webflow templates.
             
            
              Hire a Webflow expert
             
             
              Partner with a certified expert.
             
            Is it possible to recreate an image carousel with mouse-based movement in Webflow?
             Published on
            
            
             September 22, 2023
            
           Yes, it is possible to recreate an image carousel with mouse-based movement in Webflow. Below are the steps to achieve this:
- Create a new section on your page where you want the image carousel to appear.
 - Inside the section, add a new div element and give it a class name, such as "carousel-wrapper".
 - Inside the "carousel-wrapper" div, add a new div element and give it a class name, such as "carousel-slide".
 - Add all your carousel items (e.g., images) inside the "carousel-slide" div. Each item should be placed inside a separate div or link block, and each div or link block should have a class name (e.g., "carousel-item").
 - Set the width of the "carousel-slide" div to accommodate all your carousel items. For example, if you have three carousel items with a width of 300px each, set the width of "carousel-slide" to 900px (3 items * 300px).
 - Style the "carousel-slide" class by giving it a "display: flex" property and set "overflow: hidden" to hide any overflow.
 - Apply a "flex" or "grid" display property to the "carousel-item" class to arrange the items horizontally.
 - Add custom code to make the carousel slide horizontally based on mouse movement. Use the Webflow Designer to access the custom code section and paste the following JavaScript code:
 
var carousel = document.querySelector('.carousel-slide');var isDown = false;var startX;var scrollLeft;carousel.addEventListener('mousedown', function(e) {    isDown = true;    startX = e.pageX - carousel.offsetLeft;    scrollLeft = carousel.scrollLeft;    carousel.classList.add('active');});carousel.addEventListener('mouseleave', function() {    isDown = false;    carousel.classList.remove('active');});carousel.addEventListener('mouseup', function() {    isDown = false;    carousel.classList.remove('active');});carousel.addEventListener('mousemove', function(e) {    if (!isDown) return;    e.preventDefault();    var x = e.pageX - carousel.offsetLeft;    var walk = x - startX;    carousel.scrollLeft = scrollLeft - walk;});
           - Add the following custom styles to your Webflow project:
 
.carousel-slide {    scroll-snap-type: x mandatory;    -webkit-overflow-scrolling: touch;}.carousel-item {    flex: 0 0 auto;    width: 100%;}.carousel-wrapper.active {    cursor: grabbing;    cursor: -webkit-grabbing;}.carousel-wrapper.active::before {    cursor: grabbing;    cursor: -webkit-grabbing;}
           - Preview the page to see your mouse-based image carousel in action.
 
With these steps, you should be able to create a mouse-based image carousel in Webflow. Remember that you can customize the styles and animations according to your design needs.
Additional questions:
- How do I create a mouse-based image carousel in Webflow?
 - What is the process to make an image carousel with mouse-based movement in Webflow?
 - Can I implement mouse-based movement in an image carousel in Webflow?