如何在移动设备上实现全宽度的旋转木马效果
P粉302484366
P粉302484366 2023-08-31 09:17:45
[CSS3讨论组]

如何在移动手机或小屏幕设备上使我的轮播图变成全宽? 任何帮助将不胜感激。

您可以查看下面的代码,或者直接在我的CodePen上查看 - https://codepen.io/nurzamf-the-lessful/pen/ZEodKGO

<div class="contain">
  <div id="owl-carousel" class="owl-carousel owl-theme">
    <div class="item">
              <img src="https://blogger.googleusercontent.com/img/a/AVvXsEi9MjLHgzg-8RYlTEZFFZ21FGuldcTSSv2wZHf1nGh6KGgwMAznhwkDlpgyt0pxtMxODbGvftKhgPFbNp46_Jv_45WF64GI7Y5ldi6eZQSTZ5twNS3OkdGY8tBF4vo0Zun3WpLSBiTYy3dBWI0Q0fSyS_mV6PU4XyiW_WA3DcZLSnRKJmiFjG2p6D0_=s1600" class="img-responsive" />
    </div>
    <div class="item">
      <img src="https://blogger.googleusercontent.com/img/a/AVvXsEiTZxD__KXQgaGHq_Xm_Jy7kA44vsdwijCR4VrsJI5uGDptJYp2ujRiVX6_6hNA-mCkh9OezjOBddFRYoAVGIT5omKqQcZnn8mFPtyae72oS7I-_pBQs2-5UnYTZ6VVIyBwQQL6RNJrOPjXiiV1jyHBRDOIxi_6Yyw8Nh2hRZfgrYgJiG_F4ljNnJ4J=s1600" class="img-responsive" />
    </div>
    <div class="item">
      3
    </div>
    <div class="item">
      4
    </div>
    <div class="item">
      5
    </div>
    <div class="item">
      6
    </div>
  </div>
</div>
.contain {
  width: 100%;
}

.item {
 width:100%;
  color: white;
  display: block;
}
$('#owl-carousel').owlCarousel({
    loop: true,
    margin: 0,
    dots: true,
    nav: true,
    items: 2,
})

P粉302484366
P粉302484366

全部回复(1)
P粉170438285

希望它对你有用!!!

jQuery(document).ready(function(){
            jQuery('#owl-carousel').owlCarousel({
                loop: true,
                margin: 0,
                dots: true,
                nav: true,
                items: 2,
                responsiveClass:true,
                responsive:{
                    1000:{
                        items:2,
                        nav:true,
                        loop:true
                    },
                    600:{
                        items:1,
                        nav:true,
                        loop:true
                    },
                    0:{
                        items:1,
                        nav:true,
                        loop:true
                    }
                }
            });
        });
.contain {
    width: 100%;
}

.item {
     width:100%;
     color: white;
     background-color: salmon;
     display: block;
}
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Dashboard</title>
    
    <link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css" rel="stylesheet" />  
      
    

    </head>
    <body>

    <div class="contain">
      <div id="owl-carousel" class="owl-carousel">
        <div class="item">
                  <img src="https://blogger.googleusercontent.com/img/a/AVvXsEi9MjLHgzg-8RYlTEZFFZ21FGuldcTSSv2wZHf1nGh6KGgwMAznhwkDlpgyt0pxtMxODbGvftKhgPFbNp46_Jv_45WF64GI7Y5ldi6eZQSTZ5twNS3OkdGY8tBF4vo0Zun3WpLSBiTYy3dBWI0Q0fSyS_mV6PU4XyiW_WA3DcZLSnRKJmiFjG2p6D0_=s1600" class="img-responsive" />
        </div>
        <div class="item">
          <img src="https://blogger.googleusercontent.com/img/a/AVvXsEiTZxD__KXQgaGHq_Xm_Jy7kA44vsdwijCR4VrsJI5uGDptJYp2ujRiVX6_6hNA-mCkh9OezjOBddFRYoAVGIT5omKqQcZnn8mFPtyae72oS7I-_pBQs2-5UnYTZ6VVIyBwQQL6RNJrOPjXiiV1jyHBRDOIxi_6Yyw8Nh2hRZfgrYgJiG_F4ljNnJ4J=s1600" class="img-responsive" />
        </div>
      </div>
    </div>



    
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.js"></script>
   
    </body>
</html>
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号