How can I add scroll bar on bottom in scroll slider

How can I add scroll bar on bottom in scroll slider

Aleksander22
Explorer
115 0 40

 

Hello,

I got a question. Is it possible to add scroll bar in my product slider. Becuse I’m my theme it’s not possible. I need scroll like on the example

IMG_0944.png

Like when you scrolling it’s increasing size to the right

Replies 15 (15)

Hamza_takkar
Excursionist
36 3 5

Hi Aleksander22 , our team will help you  ,

 

  • Locate the Slider Code: Find the section in your Shopify theme where the product slider is implemented. This could typically be in sections or snippets, such as product-slider.liquid or something similar.

  • Wrap the Slider with a Scrollable Container: Add a wrapper around your slider with overflow-x: auto to enable horizontal scrolling. This can be done by modifying the Liquid file where the slider is coded.

    liquid
    Copy code
    <div class="scrollable-slider-container"> <div class="product-slider"> {% for product in collection.products %} <!-- Your product card code goes here --> <div class="product-card"> <!-- Product image, title, price, etc. --> </div> {% endfor %} </div> </div>
  • Add CSS for the Scrollbar: You need to add some CSS to make the container scrollable and style the scrollbar if needed.

    css
    Copy code
    .scrollable-slider-container { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; /* Enables smooth scrolling on iOS devices */ } .product-slider { display: inline-block; /* Keeps the slider content in a single line */ } .product-card { display: inline-block; /* Displays product cards side by side */ width: 200px; /* Adjust width as needed */ margin-right: 10px; /* Space between each product card */ } /* Optional: Custom scrollbar styles */ .scrollable-slider-container::-webkit-scrollbar { height: 8px; /* Height of horizontal scrollbar */ } .scrollable-slider-container::-webkit-scrollbar-thumb { background-color: #888; /* Scrollbar thumb color */ border-radius: 10px; /* Rounded scrollbar thumb */ } .scrollable-slider-container::-webkit-scrollbar-thumb:hover { background-color: #555; /* Hover color for scrollbar thumb */ }

 

 

 

 


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks

Aleksander22
Explorer
115 0 40

@Hamza_takkar i send you message on priv 

Hamza_takkar
Excursionist
36 3 5

hey , Thanks for reaching out ,

 

  • Go to your Shopify Admin Dashboard.
  • Navigate to Online Store > Themes.
  • Click on the "Actions" button next to your current theme and select "Edit code".
  • In the Sections folder, click "Add a new section".
  • Name the new section product-slider 
  • Once you've created the new section, it will open in the code editor. Replace any existing code in product-slider.liquid with the following:

    {% comment %}
    Product Slider Section
    {% endcomment %}

    <div class="scrollable-slider-container">
    <div class="product-slider">
    {% assign products = collections['your-collection-handle'].products %}
    {% for product in products %}
    <div class="product-card">
    <!-- Product Image -->
    <a href="{{ product.url }}" class="product-image">
    <img src="{{ product.featured_image | img_url: 'medium' }}" alt="{{ product.title }}">
    </a>

    <!-- Product Title -->
    <div class="product-title">
    <a href="{{ product.url }}">{{ product.title }}</a>
    </div>

    <!-- Product Price -->
    <div class="product-price">
    {{ product.price | money }}
    </div>
    </div>
    {% endfor %}
    </div>
    </div>

     

    Replace 'your-collection-handle' with the handle of the collection you want to display. You can find this handle in the Collections section of your Shopify admin.

Next, you need to add the CSS code to make the slider scrollable. Follow these steps:

  1. In the Shopify code editor, navigate to the Assets folder.
  2. Open your theme's CSS file (often named theme.css or theme.scss.liquid).
  3. Add the following CSS at the bottom of the file:

.scrollable-slider-container {
overflow-x: auto;
white-space: nowrap;
-webkit-overflow-scrolling: touch; /* Enables smooth scrolling on iOS devices */
margin: 0 auto; /* Centers the slider on the page */
padding: 20px 0; /* Adds padding around the slider */
}

.product-slider {
display: inline-block; /* Keeps the slider content in a single line */
width: max-content; /* Ensures the slider's width fits all product cards */
}

.product-card {
display: inline-block; /* Displays product cards side by side */
width: 200px; /* Adjust width as needed */
margin-right: 10px; /* Space between each product card */
box-shadow: 0 4px 8px rgba(0,0,0,0.1); /* Adds a subtle shadow */
background-color: #fff; /* Background color for each card */
border-radius: 5px; /* Rounded corners for cards */
overflow: hidden; /* Ensures content doesn't overflow the card */
text-align: center; /* Centers text within each product card */
padding: 10px; /* Adds padding inside each card */
}

/* Optional: Custom scrollbar styles */
.scrollable-slider-container::-webkit-scrollbar {
height: 8px; /* Height of horizontal scrollbar */
}

.scrollable-slider-container::-webkit-scrollbar-thumb {
background-color: #888; /* Scrollbar thumb color */
border-radius: 10px; /* Rounded scrollbar thumb */
}

.scrollable-slider-container::-webkit-scrollbar-thumb:hover {
background-color: #555; /* Hover color for scrollbar thumb */
}

 

To make the slider more interactive with a drag-to-scroll feature, add Javascript&colon;

  1. In the Shopify code editor, go to the Assets folder.
  2. Find and open your JavaScript file (often named theme.js or custom.js).
  3. Add the following JavaScript at the bottom:

document.addEventListener('DOMContentLoaded', function () {
const slider = document.querySelector('.scrollable-slider-container');

let isDown = false;
let startX;
let scrollLeft;

slider.addEventListener('mousedown', (e) => {
isDown = true;
slider.classList.add('active');
startX = e.pageX - slider.offsetLeft;
scrollLeft = slider.scrollLeft;
});

slider.addEventListener('mouseleave', () => {
isDown = false;
slider.classList.remove('active');
});

slider.addEventListener('mouseup', () => {
isDown = false;
slider.classList.remove('active');
});

slider.addEventListener('mousemove', (e) => {
if (!isDown) return;
e.preventDefault();
const x = e.pageX - slider.offsetLeft;
const walk = (x - startX) * 2; // Adjusts scroll speed
slider.scrollLeft = scrollLeft - walk;
});
});

 

 

Now that you have created the new section, you need to add it to a page or template.

  1. Go to the Shopify code editor and open Templates/index.liquid (or any page template where you want to display the slider).
  2. Include the new section by adding the following code where you want the slider to appear:

 

liquid
 
{% section 'product-slider' %}

 

  1. Save all the changes in your Shopify theme editor.
  2. Preview your store to see the new product slider with a scrollbar.

 


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks

Aleksander22
Explorer
115 0 40

I got a question becuse I have already product slider so can’t name this section the same. So how to name it @Hamza_takkar 

Hamza_takkar
Excursionist
36 3 5

ok , can you give me a collaborative access to the shop so i can check it out .

 


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks

Aleksander22
Explorer
115 0 40

@Hamza_takkar Yeah here is code 5573

Hamza_takkar
Excursionist
36 3 5

please also share your store URL ending with .myshopify.com


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks

Aleksander22
Explorer
115 0 40

It’s just glovyzone.com

Hamza_takkar
Excursionist
36 3 5

Hamza_takkar_0-1725359569172.png

 


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks

Aleksander22
Explorer
115 0 40

I removed the code that you send becuse I thought I’m gonna do something wrong. So you have to add code again

Hamza_takkar
Excursionist
36 3 5

i have requested , please accept it so i can check it out 👍


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks

Aleksander22
Explorer
115 0 40

I accepted it 

Hamza_takkar
Excursionist
36 3 5

scrolltest.png

check it in duplicate theme , it seem someone has already done it before me , while i was working on it .


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks

Aleksander22
Explorer
115 0 40

@Hamza_takkar Yeah it was in my previous site. So can you help me to add this to my current them

Hamza_takkar
Excursionist
36 3 5

ok doing it  now


-Need a Shopify Specialist? Chat on

 

Whastapp



- Custom Design | Advanced Coding | Store Modifications


Thanks