响应式iframe轮播模式?

问题描述 投票:0回答:1

我想在我的Tumblr中添加一个基于弹出式/模态div的轮播(由于缺乏更好的用语,我不希望有一个简单的图像轮播),可以通过底部对齐的菜单直接在菜单中进行导航模态或作为iframe。由于无法找到资源来构建前一种方法,因此我选择了后者。虽然视口单位似乎通常使待框架页面正确地响应宽度(右偏移增加,较大的vw无法解决),但是当我调整源页面大小或将其填充到页面中时,高度响应会中断。最终模式,使我无法访问导航菜单。如何使iframe轮播正确响应尺寸;还是有人可以向我指出构建弹出式div轮播的正确方法?这是我的困境的JSFiddle,也是the iframed page(可通过pastebin访问的代码)。

HTML:

<div id="main">
    <ul id="nav">
        <li class="changer changer1 active" data-slidey="1"><span>ITEM 1</span></li><!--
        --><li class="changer changer2" data-slidey="2"><span>ITEM 2</span></li><!--
        --><li class="changer changer3" data-slidey="3"><span>ITEM 3</span></li><!--
  --><li class="changer changer4" data-slidey="4"><span>ITEM 4</span></li>
  <li class="changer changer5" data-slidey="5"><span>ITEM 5</span></li>
</ul>

    <div id="carousel" class="slidey1"><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
        </div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
        </div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
        </div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
</div><!--
  --><div class="box">
<iframe frameborder="0" id="owl" scrolling="yes" src="URL" width="100%" height="100%"></iframe>
</div>
</div>
</div>

CSS:

        #main {
            background:#fff;
            border:1px solid #eaeaea;
            height:100vw;
            width:100vw;
            text-align:center;
            padding:25px;
            font-family:'open sans', sans-serif;
            font-size:11px;
            overflow:hidden;
        }
        ul#nav {
            padding:0;
            margin:0;
            list-style:none;
            width:100vw;
            position:absolute;
            bottom:0vw;
            padding-top:15px;
            border-top:1px solid #eaeaea;
            color:#222;
            display:flex;
        }
        ul#nav li {
            display:inline-block;
            width:100px;
            overflow:hidden;
            line-height:20px;
            font-size:11px;
            text-transform:uppercase;
            letter-spacing:1.1px;
            cursor:pointer;
            position:relative;
            font-weight:bold;
            flex:1;
        }

[...]

        #carousel {
            width:500vw;
            position:absolute;
            top:10px;
            text-align:left;
        }
        .slidey1 {
            margin-left: 0vw;
            -webkit-transition: all 0.3s linear;
            -moz-transition: all 0.3s linear;
            -o-transition: all 0.3s linear;
            transition: all 0.3s linear;
        }

        /* my actual code contains 5 different slidey# classes, with the slidey number increasing by 1 (up 
           to .slidey4) and the margin-left decreasing by 100vw (down to -400vw) */

        .box {
            height:92vh;
            padding:0 15px;
            display:inline-block;
            width:94.5vw;
            vertical-align:top;
            margin-right:25px;
            text-align:center;
        }

JS:

       (function($){ $(document).ready(function(){ $("[title],a[title],img[title]").style_my_tooltips({ tip_follows_cursor:true, tip_delay_time:100, tip_fade_speed:300, attribute:"title" }); }); })(jQuery);
       $(document).ready(function() {
          $(".changer").click(function(){
            $("#carousel").removeClass();
            $("#carousel").addClass("slidey" + $(this).data("slidey"));
            $(".changer1, .changer2, .changer3, .changer4, .changer5").removeClass("active");
            $(".changer" + $(this).data("slidey")).addClass("active");
            return false;
        });
          $('ul.tags li a').on({
           mouseenter: function() {
               $(this).parent().addClass('hovered');
           },
           mouseleave: function() {
               $(this).parent().removeClass('hovered');
           }
       });
      })

谢谢!

jquery html css carousel popupwindow
1个回答
0
投票

因此,如果我做对了,您想要在您制作的模态中放置一个好的旋转木马。

而且据我所知,您正在使用JQuery库。因此,这里有一个响应快速且易于制作的轮播库,它称为Owl Carousel,在我的项目中我已经使用了很多。

Owl Carousel link

编辑:这是猫头鹰轮播的实时示例:

$('.owl-carousel').owlCarousel({
    loop:true,
    margin:10,
    nav:true,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
    }
})
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css" rel="stylesheet"/>

<div class="owl-carousel owl-theme">
  <item>
    <img src="https://picsum.photos/300" alt="">
  </item>
  <item>
    <img src="https://picsum.photos/300" alt="">
  </item>
  <item>
    <img src="https://picsum.photos/300" alt="">
  </item>
  <item>
    <img src="https://picsum.photos/300" alt="">
  </item>
  <item>
    <img src="https://picsum.photos/300" alt="">
  </item>
  <item>
    <img src="https://picsum.photos/300" alt="">
  </item>
</div>

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>

编辑:

您可以通过编辑响应对象来更改要在任何屏幕上查看的项目数,例如:

响应:{0:{项目:1},600:{项目:1},1000:{项目:1}}

[Source/Docs]

© www.soinside.com 2019 - 2024. All rights reserved.