Owl Carousel missing some styles when the page loads

Viewed 19

I am using owl carousel as a slider but sometimes when the page loads the slider is not displayed. Inspect element tells me that the slider it's missing some styles. I have included the styles in the head of my page. I included jquery and then the owl carousel link. I am getting the data for the carousel with AJAX. This is the code

<head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.theme.min.css"> 
</head>

<body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous">

<script defer="defer" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js">  
</script>

    $(document).ready(function(){
        $("#testimonial-slider").owlCarousel({
            items:3,
            itemsDesktop:[1000,3],
            itemsDesktopSmall:[980,2],
            itemsTablet:[768,2],
            itemsMobile:[650,1],
            pagination:true,
            navigation:false,
            slideSpeed:1000,
            autoPlay:true
        });
    });
</body>
1 Answers

No style is missing on the code you shared, the problem lies somewhere else

$(document).ready(function(){
  $("#testimonial-slider").owlCarousel({
    items:3,
    itemsDesktop:[1000,3],
    itemsDesktopSmall:[980,2],
    itemsTablet:[768,2],
    itemsMobile:[650,1],
    pagination:true,
    navigation:false,
    slideSpeed:1000,
    autoPlay:true
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.theme.min.css"> 
</head>

<body>
  <script defer="defer" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js">  
  </script>
  <div id="testimonial-slider">
    <div> Slide 1</div>
    <div> Slide 2 </div>
    <div> Slide 3 </div>
  </div>
</body>

Related