【问题标题】:Owl carousel 2 using html files instead of imgOwl carousel 2 使用 html 文件而不是 img
【发布时间】:2014-08-13 16:16:06
【问题描述】:

我正在使用owl carousel 2 创建一个简单的滑动轮播。目前我只是在使用图像,但是我希望能够使用 html 文件而不是 .这些 html 文件有多个 div,可以在其中加载图像,而不是整个图像滑开,只会改变。关于我该如何做这件事有什么建议吗?

当前 HTML 文件:

<div id="carousel" class="owl-carousel">
    <div class="item"><img src="Images/1.jpg" alt="img1" /></div>
    <div class="item"><img src="Images/2.jpg" alt="img2" /></div>
    <div class="item"><img src="Images/3.jpg" alt="img3" /></div>
    <div class="item"><img src="Images/4.jpg" alt="img4" /></div>
</div>

    <script src="Scripts/jquery-1.9.0.js"></script>
    <script src="Scripts/bootstrap.js"></script>
    <script src="Scripts/owl.carousel.js"></script>
    <script src="Scripts/app.js"></script>

【问题讨论】:

    标签: javascript html owl-carousel


    【解决方案1】:

    如果您说的是 HTML 元素。那么我有一个解决方案给你。 那么让我告诉你如何使用 Owl Carousel 和 Bootstrap 创建一个客户推荐区。

    确保您已连接 owl.carousel.css、owl.theme.default.min.css 和 owlcarousel.js。

    HTML 代码

    <section id="clients-reviews" >
            <div class="container">
                        <div class="row">
                            <div class="col-lg-12 text-center">
                                <div id="owl-client-reviews" class="owl-carousel owl-theme">
                                    <div class="review">
                                        <p>
                                            " 
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."
                                        </p>
                                        <br>
                                        <h4><span class="name">Salam mohd |</span>  <span class="post">web designer</span> </h4>
                                    </div>
                                    <div class="review">
                                        <p>
                                            " 
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."
                                        </p>
                                        <br>
                                        <h4><span class="name">Salam mohd |</span>  <span class="post">web designer</span> </h4>
                                    </div>
                                    <div class="review">
                                        <p>
                                            " 
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."
                                        </p>
                                        <br>
                                        <h4><span class="name">Salam mohd |</span>  <span class="post">web designer</span> </h4>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
    </section>
    

    CSS 是这样的

    #clients-reviews .review p{
        font-family: 'PT Serif Caption', serif;
        color: #ffffff;
        font-size: 18px;
    }
    #clients-reviews .review span.name{
    
        color:#fed136;
    }
    #clients-reviews .review span.post{
            font-family: 'PT Serif Caption', serif;
        font-weight: 300;
        font-size: 14px;
        color: #fed136;
        text-transform: none;
    }
    #clients-reviews .owl-theme .owl-controls .owl-nav [class*=owl-] {
        background: transparent;
        color: #ffffff;
        bborder: 2px solid  #fed136;
        font-size: 14px;
        padding: 0 10px;
        line-height: 14px;
    }
    

    你的 JS 文件将是

     $("#owl-client-reviews").owlCarousel({
            items:1,
            loop:true,
            autoplay:true,
            autoHeight: false,
            autoHeightClass: 'owl-height',
            dots:false,
            nav:true,
            navText:[
                "<i class='fa fa-angle-left fa-2x'></i>",
                "<i class='fa fa-angle-right fa-2x'></i>"
            ]
        });
    

    注意*

    我在 next 和 pre 中使用了 Fontawesome Icons。 如果要增加项目,请使用 items 属性。

    谢谢:)

    【讨论】:

    • 感谢您的帮助 :) 我能否将此 html 文本存储在 .html 文件中并在轮播中调用该文件?我想要做的是使用数组和敲除绑定预先填充模板。然后基本上循环遍历元素数组,在一段时间后更改模板内的内容?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多