【问题标题】:Owl Carousel 2 sets itself to display noneOwl Carousel 2 将自身设置为不显示
【发布时间】:2016-04-12 20:09:51
【问题描述】:

我试图让 owl carousel 2 在我的 php 网站上运行。除了功能之外,我在 Anguler 网站上使用了完全相同的代码。所以这应该有效。这是我的脚本和链接

jQuery(document).ready(function(){
  jQuery('#owl2').owlCarousel({
    navigation: true,
    nav: true,    
    dots: false,
    margin: 50,
    dotsEach: false,
    dotData: false,
    center: true,
    autoWidth: true,
    items: 5,
    center:true,
    slideSpeed: 300,
    paginationSpeed: 400,                        
    autoPlay: false,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
        }
    });
});

html

 <div class="container">
    <div class="row">
        <div class="col-md-12">            
                <div id="owl2" class="owl-carousel owl-theme">
                    <div class="item verticle-align">
                        <img class="verticle-align" src="img/metabo.png" alt="">
                    </div>
                    <div class="item">
                        <img class="verticle-align" src="img/aeroquip.png" alt="">
                    </div>
                    <div class="item">
                        <img class="verticle-align" src="img/IR.png" alt="">
                    </div>
                    <div class="item">
                        <img class="verticle-align" src="img/huck.png" alt="">
                    </div>
                    <div class="item">
                        <img class="verticle-align" src="img/infasco.png" alt="">
                    </div>   
                    <div class="item">
                        <img class="verticle-align" src="img/metabo.png" alt="">
                    </div>   
                    <div class="item">
                        <img class="verticle-align" src="img/chicago-pneumatic.jpg" alt="">
                    </div> 
                    <div class="item">
                        <img class="verticle-align" src="img/Gesipa.jpg" alt="">
                    </div>               
                </div>            
        </div>
    </div>
</div> 

还有我的链接

 <!-- Bootstrap -->
    <link rel="stylesheet" type="text/css" href="css/boot/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/boot/bootstrap-theme.css">


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

    <!--Other CSS files-->
    <link rel="stylesheet" type="text/css" href="css/responsive.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="stylesheet" type="text/css" href="css/fa/font-awesome.css">

    <!--Jquery-->
    <script src="js/jquery-2.2.3.min.js"></script>


    <!-- Bootstrap JS -->
    <script src="js/boot/bootstrap.js"></script>
    <!--<script src="js/boot/bootstrap.min.js"></script>-->

    <!--Other Js files-->    
    <script src="js/main.js"></script>
    <script src="js/owl/owl.carousel.js"></script>

我以前做过很多次,但这次似乎无法正常工作。有人知道我做错了什么吗?

我被要求添加我在页面上使用的第二个轮播,下面是所述轮播的 html/js

<div id="owl" class="owl-carousel owl-theme">
                <div class="item first-item">
                    <div class="products-images">
                        <a href="./img/catalog/9-Assortments-Storage.pdf"     target="_blank">Assortments</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/4-Tools.pdf"               target="_blank">Tools</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/4-Tools.pdf" target="_blank">Cutting Tools</a>
                    </div>
                </div>
                <div class="item active">
                    <div class="products-images ">
                        <a href="./img/catalog/7-Brass.pdf" target="_blank">Fittings</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/6-Electrical.pdf" target="_blank">Electrical</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/1-Fasteners.pdf" target="_blank">Fasteners</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/2014Safety.pdf" target="_blank">Saftey</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/5-ShopSupplies.pdf" target="_blank">Shop Supplies</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/2-Rivets-Huck.pdf" target="_blank">Rivets</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/2014CustomPackaging.pdf" target="_blank">Custom Packaging</a>
                    </div>
                </div>
                <div class="item">
                    <div class="products-images">
                        <a href="./img/catalog/3-Chemicals.pdf" target="_blank">Chemicals</a>
                    </div>
                </div>
            </div>
<script type="text/javascript">
jQuery(document).ready(function(){
  jQuery('#owl').owlCarousel({
    navigation: true,
    nav: true,    
    dots: false,
    dotsEach: false,
    dotData: false,
    center: true,
    autoWidth: true,
    items: 7,
    center:true,
    slideSpeed: 300,
    paginationSpeed: 400,                        
    autoPlay: false,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
        }
    });
});
</script>

【问题讨论】:

  • 看起来有错别字。您的 owl div 的 ID 是 owl2,但在初始化轮播的 jQuery 中,您将其命名为 owl
  • 那么(不)发生了什么?轮播图没有显示?
  • 正确@Marcus 轮播根本不显示
  • JavaScript 错误?发布任何/所有可能有帮助的东西。据我所知js/owl/owl.carousel.js 不是正确的道路,知道我的意思吗?你的调试工具(Chrome/Firefox)说什么?有什么事吗?
  • @Marcus 遗憾的是没有 JS 错误,什么都没有。我遇到这么多麻烦的原因之一,我也尝试了几乎所有版本的 jQuery,我在这里看到某个地方说这可能是问题所在,遗憾的是它不起作用

标签: php jquery twitter-bootstrap owl-carousel-2


【解决方案1】:

已解决

所以问题似乎是我的 owl.carousel.min.js 文件和我的 css 文件,我在开始时下载了最新版本。但是当使用这个链接时

    <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.0.0-beta.3/owl.carousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.0.0-beta.3/assets/owl.carousel.min.css">
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.0.0-beta.3/assets/owl.theme.default.min.css">

它开始工作了。不确定我下载的文件是否以某种方式损坏,但没关系。它现在工作。希望这对将来的人有所帮助!

特别感谢@Marcus,他昨天与我交谈了一段时间,试图帮助我解决这个问题。多谢大佬!

【讨论】:

    【解决方案2】:

    id="owl2" 更改为id="owl"

    或将('#owl') 更改为('#owl2')。随你喜欢。

    【讨论】:

    • 对不起,我有 2 个轮播,我没有注意到我发布了错误的代码,我刚刚进行了更正。感谢您了解
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-21
    • 2020-08-15
    • 1970-01-01
    相关资源
    最近更新 更多