The container width is too wide for the swiper arrow to display properly

Errors encountered when displaying arrows over the width

<Swiper 
                    slidesPerView={5}
                    spaceBetween={20} 
                    pagination={{ 
                        clickable: true, 
                    }} 
                    navigation={{
                        prevEl: navigationPrevRef.current,
                        nextEl: navigationNextRef.current
                    }}

                    onSwiper={(swiper) => {
                        // Delays execution for ref definitions
                        setTimeout(() => {
                            // Update prevEl & nextEl with defined refs
                            swiper.params.navigation.prevEl = navigationPrevRef.current
                            swiper.params.navigation.nextEl = navigationNextRef.current
                    
                            // Re-initialize navigation
                            swiper.navigation.destroy()
                            swiper.navigation.init()
                            swiper.navigation.update()
                        })
                    }}

                    breakpoints={{
                        640: {
                            slidesPerView: 2,
                            spaceBetween: 20,
                        },
                        768: {
                            slidesPerView: 4,
                            spaceBetween: 40,
                        },
                        1024: {
                            slidesPerView: 5,
                            spaceBetween: 50,
                        },
                    }}
                    modules={[Pagination, Navigation]}
                    className='category-slider'
                >
                    <SwiperSlide>
                        <div className="category-card">
                            <img src="https://clicon-html.netlify.app/image/product/product-14.png" alt="" className='category-image' />
                            <h6 className="category-text">TV & Homes</h6>
                        </div>
                    </SwiperSlide>>
                    
                    // Additional SwiperSlides here

                    <button className="slick-arrow-carousel button-prev" ref={navigationPrevRef}>
                        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                            // SVG paths for previous button
                        </svg>

                    </button>

                    <button className="slick-arrow-carousel button-next" ref={navigationNextRef}>
                        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                            // SVG paths for next button
                        </svg>
                    </button>
            
                </Swiper> 

styles.css

.category-slider{
    position: relative;    
}

// Additional CSS styles here

Encountering issues with displaying arrows over the full width in Swiper Carousel, despite setting z-index: 99999. Seeking solutions and suggestions for resolving this problem.

Require assistance with understanding and resolving Swiper Carousel properties.

Answer №1

After careful investigation, I attempted to reproduce the issue within my react application using swiper version 11.0.7. Please find the updated code below for reference:

import { Swiper, SwiperSlide } from 'swiper/react';
import { Navigation } from 'swiper/modules';
import 'swiper/css';
import 'swiper/css/navigation';
import 'swiper/css/pagination';
import './index.css'; 

const SwiperCarousel = () => {
    return (
      <div className='category-slider'>       
        <Swiper
          modules={[Navigation]}
          onSwiper={(swiper) => console.log(swiper)}
          onSlideChange={() => console.log('slide change')}
          spaceBetween={25}
          slidesPerView={5}
          navigation={{
            nextEl: '.review-swiper-button-next',
            prevEl: '.review-swiper-button-prev',
          }}
        >
            <SwiperSlide>
                <div className="category-card">
                    <img src="https://clicon-html.netlify.app/image/product/product-14.png" alt="" className='category-image' />
                    <h6 className="category-text">TV & Homes</h6>
                </div>
            </SwiperSlide>
            {/* Additional SwiperSlide elements replicated for testing */}
          </Swiper>
          <button className="slick-arrow-carousel button-prev review-swiper-button-prev">
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M20.25 12H3.75" stroke="white" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"></path>
                <path d="M10.5 5.25L3.75 12L10.5 18.75" stroke="white" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"></path>
            </svg>
          </button>
          {/* Additional button element replicated for testing */}
      </div>
    );
}

export default SwiperCarousel;

I have also made modifications to the CSS. Feel free to adjust as needed:

.category-slider {
  width: 90% !important;
  position: relative;
  margin: 80px auto;
  text-align: center;
}
.category-slider .swiper {
  padding-right: 14px !important;
}
.category-slider .swiper-slide {
  border: 1px solid;
}
/* Additional CSS styles replicated for demonstration */

Kindly test the provided code and CSS modifications. Let me know if it resolves the issue for you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I dynamically change the CSS position property from 'relative' to 'absolute' based on the Y scroll value in an Animated.ScrollView in React-Native?

I have implemented an animated header that shrinks and increases opacity as the scroll view is being scrolled down. Below the animated header, there is a filter bar that needs to stay fixed just under the animated header once it has fully clamped. I have m ...

Struggling to understand how to personalize a D3 generated graph

Currently, I am utilizing react-d3 instead of the Plotly react wrapper due to some bugs in the latter. My issue now lies in understanding the d3 API as I am unable to fully grasp it. I have successfully created a scatter plot similar to the one shown on ...

Unlock the innerHTML of a DIV by clicking a button with ng-click in Angular JS

I am curious about something. There is a <div> and a <button> in my code. I am looking to access the inner markup of the <div> within the ng-click function without relying on jQuery. Can you give me some guidance? <div id = text-entry ...

Mixing percentage width with a fixed minimum width in CSS results in divs failing to align in a single line

Having an issue with the responsiveness of a website layout that includes three columns (let's say 'A', 'B', and 'C') each 96% high, along with a footer. Columns A and C have a width of 35%, while column B is set to be 30 ...

The ReactDom reference is not defined when working with React and webpack

After following a tutorial on React and webpack from jslog.com, I encountered issues with using updated syntax such as using ReactDom to call render instead of the deprecated 'React.renderComponent'. I tried running: npm install --save react-do ...

What is causing my Next.js application to not generate a build directory when I execute npm run build within the React environment?

I have been facing a challenge with my next.js project as I attempt to use npm run build to compile it for hosting on hostinger. Despite being notified of successful compilation every time I run npm run build, I am unable to locate the folder anywhere. Any ...

Creating a CSS layout that eliminates the need for a vertical scroll bar

Currently, I am experimenting with creating an HTML CSS Layout using the div tag. You can view the code here Currently, the layout displays a vertical bar that I would like to eliminate. Ideally, I only want it to display if the content is lengthy. ...

The issue with Next.js is that cookies are not being transmitted along with fetch requests, even when credentials are

I've been developing a Next.js application that originally started as a regular React app created using create-react-app. I'm facing an issue where the cookies are not being sent with my fetch request to the server, despite setting credentials: & ...

Creating a Bootstrap 4.1 dropdown submenu on hover: A step-by-step guide

Currently, I am developing a website and I am looking to implement a dropdown submenu on hover using Bootstrap 4.1. Here is the HTML code snippet I have utilized to create the hover dropdown menu: <div class="navbar-collapse text-center" id="navbarRes ...

Tips for adjusting the height and border of Bootstrap tabs

I'm facing an issue with the modal and nav-tabs I created. There are a couple of problems that need to be addressed. Firstly, the tabs have excessive height and I've tried adjusting it using CSS height property, but it's not working as e ...

TypeScript React Object.assign method return type

I have a unique custom function that utilizes Object.assign to return a specific result. The documentation mentions that this function returns an array, but surprisingly, it can be destructured both as an array and an object. Check out the code snippet be ...

Trouble with integrating useEffect with socket.on in my component

In my component ListeRoom, I am facing an issue with my useEffect as it is not fetching any information on the client side. However, on the server side, when I use console.log in getActiveRooms(), I can see that the list of all active rooms is being return ...

Concealing the WordPress sidebar specifically for mobile phones, excluding iPads, tablets, and other devices

I currently have Google AdSense displayed in the sidebar of my website, but it appears distorted when viewed on a mobile phone. My objective is to eliminate the sidebar when the site is accessed via a mobile device, while maintaining it for all other devic ...

What is the best way to retrieve the border-color inline style using jQuery?

I have a HTML tag like this. <span id="createOrderFormId:accountNo" style="border-color: red;"><</span> To retrieve the style value for the border-color property, I tried using the following jQuery code: $( document ).ready(function() { ...

Unable to instantiate a class using a module in React

I am on a mission to combine Monaco editor and Convergence in order to create a collaborative editor. To achieve this goal, I am referencing the following repositories and examples: https://github.com/convergencelabs/monaco-collab-ext https://github.com/c ...

Is there an alternative to using CSS units of measurement when using the .css() method?

Is there a way to use .scrollTop() and .css() to adjust the margins of an element so that it floats up only when the page is scrolled, but stops at a certain margin value? I want the element to float between specific values while scrolling. The issue I am ...

Change the filter items operator to "OR" from "AND"

Currently tackling the XGrid project, I'm faced with the task of filtering rows based on checkboxes selected on my page. I've been attempting to pass items into the filterItems prop to create multiple filters, but I'm struggling to figure ou ...

What is the best way to remove empty elements from an Array?

Having an issue with my API post request. If no values are entered in the pricing form fields, I want to send an empty array. I attempted to use the filter method to achieve this but it still sends an array with an empty object (i.e. [{}]) when making the ...

I am facing a challenge with embedding Microsoft Dynamics CRM Dashboards on my website using React Apps as they are not allowing me to use iFrame

<iframe src="http://prodCRM" sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-pointer-lock allow-top-navigation" width="100%" height="100%"></iframe> After trying to embed the abo ...

What is the best way to display a number or integer using axios?

Need help retrieving the integer from the response obtained through an axios get request Here is what I see in the console log: https://i.stack.imgur.com/ztmf0.png setDappList([response.data.stats]); <div>{setDappList.total}</div> Unfortuna ...