Owl Carousel is not working in my code. What is going wrong?

Viewed 60

My owl carousel is not showing up when I try to run it. I linked to the correct stylesheets and to the correct script - but I see nothing.

I tried linking to the stylesheets both locally and directly from the carousel github - but I am still getting nothing.

Is it possible some code in the head is blocking the execution?

<!DOCTYPE html>
<html lang="en" style="height: 300px;">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="">
        <meta name="author" content="">
        <title>Blank Template for Bootstrap</title>
        <!-- Bootstrap core CSS -->
        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <!-- Custom styles for this template -->
        <link rel="stylesheet" href="blocks.css">
        <link href="style.css" rel="stylesheet">
        <script>/* Pinegrow Interactions, do not remove */ (function(){try{if(!document.documentElement.hasAttribute('data-pg-ia-disabled')) { window.pgia_small_mq=typeof pgia_small_mq=='string'?pgia_small_mq:'(max-width:767px)';window.pgia_large_mq=typeof pgia_large_mq=='string'?pgia_large_mq:'(min-width:768px)';var style = document.createElement('style');var pgcss='html:not(.pg-ia-no-preview) [data-pg-ia-hide=""] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show=""] {opacity:1;visibility:visible;display:block;}';if(document.documentElement.hasAttribute('data-pg-id') && document.documentElement.hasAttribute('data-pg-mobile')) {pgia_small_mq='(min-width:0)';pgia_large_mq='(min-width:99999px)'} pgcss+='@media ' + pgia_small_mq + '{ html:not(.pg-ia-no-preview) [data-pg-ia-hide="mobile"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="mobile"] {opacity:1;visibility:visible;display:block;}}';pgcss+='@media ' + pgia_large_mq + '{html:not(.pg-ia-no-preview) [data-pg-ia-hide="desktop"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="desktop"] {opacity:1;visibility:visible;display:block;}}';style.innerHTML=pgcss;document.querySelector('head').appendChild(style);}}catch(e){console&&console.log(e);}})()</script>
        <link rel="stylesheet" href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.carousel.min.css">
        <link rel="stylesheet" href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.theme.default.min.css"> 
    </head>
    <body>
        <div class="container">
</div>
        <!-- Bootstrap core JavaScript
    ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <nav class="navbar navbar-expand-lg navbar-light bg-light"> 
            <div class="container-fluid"> 
                <a class="navbar-brand" href="#">Navbar</a> 
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggler11" aria-controls="" aria-expanded="false" aria-label="Toggle navigation"> 
                    <span class="navbar-toggler-icon"></span> 
                </button>                 
                <div class="collapse navbar-collapse" id="navbarToggler11"> 
                    <ul class="navbar-nav me-auto mb-2 mb-lg-0"> 
                        <li class="nav-item"> 
                            <a class="nav-link active" href="#">Home</a> 
                        </li>                         
                        <li class="nav-item"> 
                            <a class="nav-link" href="#">Link</a> 
                        </li>                         
                        <li class="nav-item"> 
                            <a class="nav-link disabled" href="#">Disabled</a> 
                        </li>                         
                        <li class="nav-item dropdown"> 
                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink12" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">                                        Dropdown link                                    </a> 
                            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink12"> 
                                <a class="dropdown-item" href="#">Action</a> 
                                <a class="dropdown-item" href="#">Another action</a> 
                                <a class="dropdown-item" href="#">Something else here</a> 
                            </div>                             
                        </li>                         
                    </ul>                     
                    <form class="d-flex"> 
</form>                     
                </div>                 
            </div>             
        </nav>
        <div class="owl-carousel owl-theme"> 
            <div>
                <img src="https://www.w3schools.com/css/img_fjords.jpg" alt="">
            </div>             
            <div>
                <img src="https://www.w3schools.com/css/img_fjords.jpg" alt="">
            </div>             
            <div>
                <img src="https://www.w3schools.com/css/img_fjords.jpg" alt="">
            </div>             
            <div>
                <img src="https://www.w3schools.com/css/img_fjords.jpg" alt="">
            </div>             
        </div>
        <section style="height: 400px; background-attachment: fixed; background-position: center; background-size: cover; background-repeat: no-repeat; background-image: url('Downloads/jeriden-villegas-VLPUm5wP5Z0-unsplash%20(1).jpg');" data-pg-ia-scene='{"l":[{"a":"pxBckElement"}]}'>
            <section style="height: 400px; background-attachment: fixed; background-position: center; background-size: cover; background-repeat: no-repeat; opacity: 0.2; background-color: #3eaedf;" data-pg-ia-scene='{"l":[{"a":"pxBckElement"}]}'></section>
        </section>
        <script src="assets/js/popper.min.js"></script>
        <script src="bootstrap/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script type="text/javascript" src="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/owl.carousel.js"></script>
        <script src="pgia/lib/pgia.js"></script>
    </body>
</html>
1 Answers

You are doing it right with the stylesheets and scripts. You are just missing a script to initiate the carousel with its parameters. I am attaching the script and screenshots here, It is working perfect now: Owl Carousel Working Perfect

Owl Carousel MUST script to show output The following script you have to add after all the script tags in your code: <script> $('.owl-carousel').owlCarousel({ loop:true, margin:10, responsiveClass:true, responsive:{ 0:{ items:1, nav:true }, 600:{ items:3, nav:false }, 1000:{ items:5, nav:true, loop:false } } }) </script>

Let me know if you need any further help in this regard.

Related