Categories: CSSScriptWeb Design

Responsive, Mobile-friendly Carousel Slider with CSS Grid – GridSlider

GridSlider is a lightweight JavaScript library that creates responsive, accessible, touch-enabled carousels using CSS Grid layout.

Table of Contents

Toggle

Features

  • Pure JavaScript implementation: No external dependencies or framework requirements.
  • CSS Grid foundation: Uses modern CSS Grid layout for responsive behavior.
  • Touch gesture support: Native swipe functionality for mobile devices.
  • Multiple slider support: Handle multiple carousels on a single page.
  • Accessibility built-in: Keyboard navigation and ARIA labels included.
  • Customizable pagination: Flexible pager styling with CSS variables.
  • Smooth scrolling: Native scroll snapping and smooth animations.
  • Responsive design: Automatically adapts to different screen sizes.

How to use it:

1. Import the GridSlider’s JavaScript and Stylesheet into your project.

<link rel="stylesheet" href="theme.css">
<script type="module">
  import initGlider from '../index.js';
</script>

2. Create the HTML structure for your carousel. You need a main container, a grid wrapper, your slide items, and a pager element as follows:

<div class="glider glider-mq">
  <div class="glider-grid">
    <div class="glider-grid-item">1</div>
    <div class="glider-grid-item">2</div>
    <div class="glider-grid-item">3</div>
    ... more slides here
  </div>
  <div class="glider-pager"></div>
</div>

3. Initialize the scarousel in your main JavaScript file. The library will automatically find and set up all elements with the default .glider class.

initGlider();

4. Override the default CSS selector for your carousel containers.

initGlider({
  sliderSelector: '.myCarousel'
});

5. Customizing the look through CSS variables.

:root {
  --glider-spacing: 1rem;
  --glider-top-padding: 0.5rem;
  --glider-right-padding: calc((100% - 80rem) / 2 + 7.75rem);
  --glider-bottom-padding: 0.5rem;
  --glider-left-padding: 0;
  --glider-peek: 0.5;
  --glider-spacing: 1rem;
}

The post Responsive, Mobile-friendly Carousel Slider with CSS Grid – GridSlider appeared first on CSS Script.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

Cold Case unit appeals to public for information in Laureen Rahn disappearance

When 14-year-old Laureen Rahn vanished from her Manchester home at Merrimack Street four and a…

16 minutes ago

Workplace culture and birthday dinner at fault for state agency’s mishandling of ICE plans in Merrimack, report says

Poor communication, “hands-off” leadership and a birthday dinner contributed to a state agency’s deficient public…

16 minutes ago

East Concord building that holds market, apartments changes hands

Concord’s Eastside Market has a new landlord. Sarah Parker and her husband bought 11 Eastman…

16 minutes ago

NH medical marijuana program added 2,100 new patients last year

More than 2,100 new patients signed up with New Hampshire’s Therapeutic Cannabis Program last year,…

16 minutes ago

The Powerful Lenovo Legion RTX 5090 Gaming PC Drops Below $5,000 for the First Time in 2026

Lenovo's most powerful Legion gaming PC is back in stock, but not only that, it's…

31 minutes ago

Star Wars: Maul – Shadow Lord Season 1 Finale Review

Warning: This review contains full spoilers for Star Wars: Maul - Shadow Lord Episodes 9…

31 minutes ago

This website uses cookies.