The alignment issue of Owl Carousel card being off-center

I can't seem to get my owl carousel properly centered on my website. I've set up the owl carousel to showcase customer testimonials on my landing page, but it's slightly off to the right and not aligning correctly with the testimonial title. Despite trying different solutions like adjusting the width of the carousel, checking for HTML errors, and even rewriting the JS code, nothing seems to fix the issue. Anyone have any insight into what might be causing this problem and how to center the owl carousel correctly?

Here's the code snippet:

.owl-item.center .testimonial-card {
            transform: scale(0.8);
            background-color: rgba(255, 255, 255, 0.9);
            box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.9);
        }
        
        .testimonial-card {
            width: 500px;
            padding: 20px;
            display: flex;
            flex-direction: row;
            border-radius: 20px;
            background: white;
            box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.9);
            text-align: center;
            align-content: space-evenly;
            justify-content: center;
            transform: scale(0.5);
            transition: transform 0.3s cubic-bezier(0.4, 0, 1, 1);
        }
        
        .testimonial-content {
            display: flex;
            flex-direction: column;
        }
        
        .testi-img {
            width: 100%;
            height: 100%;
            position: relative;
        }

.testi-title {
            background-color: #FFF;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 1);
            text-align: center;
            border-radius: 40px;
            margin-top: 30px;
            padding: 30px;
            width: 40%;
            margin-inline: auto;
            font-weight: bold;
        }
  $(".owl-testimonials").owlCarousel({
        loop: true,
        item: 3,
        startPosition: 1,
        center: true,
        autoplay: false,
        autoplayTimeout: 3000,
        autoplayHoverPause: true,

    });
<div class="testi-title"> Testimonial</div>
    <section class="owl-carousel owl-testimonials">
        <div class="testimonial-card">
            <img class="testi-img" src="images/team/team2.jpg" alt="Testimonial 1">
            <div class="testimonial-content">
                <span class="date">1 days ago</span>
                <h4>Testimonial One</h4>
                <p>
                    Lorem ipsum dolor sit amet consectetur, Ducimus, repudiandae temporibus omnis illum maxime quod deserunt eligendi dolor
                </p>
            </div>
        </div>

        <div class="testimonial-card">

            <img class="testi-img" src="images/team/team1.jpg" alt="Testimonial 2">
            <div class="testimonial-content">
                <span class="date">1 days ago</span>
                <h4>Testimonial One</h4>
                <p>
                    Lorem ipsum dolor sit amet consectetur, Ducimus, repudiandae temporibus omnis illum maxime quod deserunt eligendi dolor
                </p>
            </div>
        </div>
        <div class="testimonial-card">

            <img class="testi-img" src="images/team/team3.jpg" alt="Testimonial 3">
            <div class="testimonial-content">
                <span class="date">1 days ago</span>
                <h4>Testimonial One</h4>
                <p>
                    Lorem ipsum dolor sit amet consectetur, Ducimus, repudiandae temporibus omnis illum maxime quod deserunt eligendi dolor
                </p>
            </div>
        </div>
    </section>

https://i.sstatic.net/0iDAt.png

Answer №1

The fixed width on the .testimonial-card class caused this issue to arise. Updating width:500px to 100% will resolve the problem. Feel free to refer to the code pen below for a detailed solution. https://codepen.io/salmanaabir/pen/vYawZYb

$( document ).ready(function() {
    $(".owl-testimonials").owlCarousel({
        loop: true,
        item: 3,
        startPosition: 1,
        center: true,
        autoplay: false,
        autoplayTimeout: 3000,
        autoplayHoverPause: true,

    });
});
.owl-item.center .testimonial-card {
  transform: scale(0.8);
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.9);
}

.testimonial-card {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: row;
  border-radius: 20px;
  background: white;
  box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.9);
  text-align: center;
  align-content: space-evenly;
  justify-content: center;
  transform: scale(0.5);
  transition: transform 0.3s cubic-bezier(0.4, 0, 1, 1);
}

.testimonial-content {
  display: flex;
  flex-direction: column;
}

.testi-img {
  width: 100%;
  height: 100%;
  position: relative;
}

.testi-title {
  background-color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 1);
  text-align: center;
  border-radius: 40px;
  margin-top: 30px;
  padding: 30px;
  width: 40%;
  margin-inline: auto;
  font-weight: bold;
}
<link rel="stylesheet" href='https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css' />
<div class="testi-title"> Testimonial</div>
    <section class="owl-carousel owl-testimonials">
        <div class="testimonial-card">
            <img class="testi-img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcg4Y51XjQ-zSf87X4nUPTQzsF83eFdZswTg&usqp=CAU" alt="Testimonial 1">
            <div class="testimonial-content">
                <span class="date">1 days ago</span>
                <h4>Testimonial One</h4>
                <p>
                    Lorem ipsum dolor sit amet consectetur, Ducimus, repudiandae temporibus omnis illum maxime quod deserunt eligendi dolor
                </p>
            </div>
        </div>

        <div class="testimonial-card">

            <img class="testi-img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcg4Y51XjQ-zSf87X4nUPTQzsF83eFdZswTg&usqp=CAU" alt="Testimonial 2">
            <div class="testimonial-content">
                <span class="date">1 days ago</span>
                <h4>Testimonial One</h4>
                <p>
                    Lorem ipsum dolor sit amet consectetur, Ducimus, repudiandae temporibus omnis illum maxime quod deserunt eligendi dolor
                </p>
            </div>
        </div>
        <div class="testimonial-card">

            <img class="testi-img" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcg4Y51XjQ-zSf87X4nUPTQzsF83eFdZswTg&usqp=CAU" alt="Testimonial 3">
            <div class="testimonial-content">
                <span class="date">1 days ago</span>
                <h4>Testimonial One</h4>
                <p>
                    Lorem ipsum dolor sit amet consectetur, Ducimus, repudiandae temporibus omnis illum maxime quod deserunt eligendi dolor
                </p>
            </div>
        </div>
    </section>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js'></script>

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

Optimizing Google e2e testing using Protractor

Improving login efficiency is necessary to enhance the speed of executing e2e tests. At present, after every test, the Chrome browser shuts down, requiring a new login session for each subsequent test. What changes can be made to address this issue? Any ...

Changing the Color of Links in Bootstrap CSS

I'm completely new to coding and I've decided to dive into the world of Bootstrap. However, I'm facing a hurdle: I can't figure out how to customize the default Bootstrap styles with my own CSS. After researching online, here are the c ...

Having trouble sending a string to the formGroup

1. I am trying to iterate through an array *ngFor="let item of myformNameArray" Assuming myformNameArray.length is 3, if I console item, it will display: myFormName1 myFormName2 myFormName3 I have already created form groups in my TypeScript component. ...

timings and pauses utilizing JavaScript

Currently, I am facing a challenge while working on a Simon Says game. My struggle lies in the part where I need to illuminate the buttons that the user has to click. I am using a "for" loop to iterate through each element in the array where I have stored ...

Updating the doctype from XHTML to the latest HTML5 standard

Currently, my .NET Master page is using an XHTML DTD: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional ... >. I am considering upgrading my .NET .ascx input controls to utilize the HTML5 placeholder attribute. From what I know, the placeholder ...

Avoid cascading of the 'display' property in JavaScript styling to prevent inheritance

Is there a way in Javascript to toggle the visibility of a larger portion of HTML without affecting inner display properties with display: <value>? Despite setting an outer display property using Javascript, the inner display properties are also alt ...

Dynamic React Hooks Input

I have a form component that allows users to add an input when clicking a button, creating new teams in which players can be added. The issue is that when filling in a value, all inputs get filled with the same value because they are using the same state. ...

Having trouble getting the header div to span the entire screen

I'm currently working on a project where I have set the header div to 100% width and the main container to also be 100% width. However, I am facing an issue where the right and left sides of the header are not filling the entire space. I managed to fi ...

PHP enables real-time control of a pop-up message box

I am currently working on a real-time project and looking for a way to send live announcements or pop-up alerts that can be controlled by admins to all users on the webpage. Although I found a solution called Realtime announcer online, our company policy ...

What Browsers are Compatible with Stream Segmentation?

Apple has developed a specification for using .m3u as a playlist file of .ts video segments. While this is known to work on iOS devices and OSX Safari, is this format supported by any other web browsers? If not, are there alternative methods available for ...

The Tailwind Typography plugin simply maintains the default font size of heading tags without altering their style

I've been working on parsing an MDX file and converting it into React components. My tech stack includes TailwindCSS, Next.js, and React. Following the Tailwind documentation, I have installed the tailwind/typography plugin. In my tailwind.config.js ...

Tips for displaying the response next to the corresponding table data (td) cell

When I click the fourth button, the response is showing on the first td. I want to show the response next to the respective td. Below is my code, can someone help me? Thanks. (i.e., here I am getting the $status using a query, but I want this status to di ...

What is the method for bringing in Mongoose to utilize json.parse()?

I'm really eager to utilize this code for importing a JSON file into JavaScript var treeData; var oReq = new XMLHttpRequest(); oReq.onload = reqListener; oReq.open("get", "test.json", true); oReq.send(); function reqListener(e) { treeData = JSON. ...

Using D3.js for Page Navigation

For my D3 bar charts, I am working with a substantial amount of JSON data obtained from an API. My goal is to display only 10-20 bars at a time. Would it be possible to implement pagination using D3 itself, or should I explore alternative methods (such a ...

Conceal sections of a three.js mesh by utilizing an alphaMap within the material

We are currently attempting to conceal certain parts of a mesh by using the alphaMap property on the material. However, we have encountered an issue where this method does not have any effect on the mesh. The code we are using is as follows: new THREE.Mes ...

Protractor - selecting a button within a table

Following the HTML code provided below, there is a table containing a list of test site links with a delete button next to each test site. /* Element locators in the table */ var testSiteLinks = element.all(by.css('a[ui-sref^="testpages"]')); ...

Identify matching values in objects and dynamically update them with a custom value

I have an array structured like this: var array = [ { dates: "2020-12-25", class: "first" }, { dates: "2020-12-26", class: "last" }, { dates: "2021-06-11", class: "first" }, ...

Utilizing 'nestjs/jwt' for generating tokens with a unique secret tailored to each individual user

I'm currently in the process of generating a user token based on the user's secret during login. However, instead of utilizing a secret from the environment variables, my goal is to use a secret that is associated with a user object stored within ...

Retrieving the value of onCheck from the Checkbox/ListItem

Imagine I have a React.Component that displays components from material-ui: {data.map(value => ( <ListItem key={data.indexOf(value)} primaryText={value} leftCheckbox={ <Checkbox onCheck={this.pr ...

Looking for guidance on sending data from a JS file to HTML using Nodejs? Seeking advice on various modules to achieve this task effectively? Let's

Looking for advice on the most effective method to transfer data from a JS file (retrieved from an sqlite db) to an HTML file in order to showcase it in a searchable table. My platform of choice is NodeJS. As a beginner, I am willing to put in extra time a ...