【问题标题】:iframe positioning on window not diviframe 在窗口而不是 div 上的定位
【发布时间】:2016-01-03 08:56:02
【问题描述】:

我目前正在改进我的网站 www.herget.design。因此我使用 CMS Koken (koken.me) 来管理我的内容并且是真正的代码。

现在我想添加功能,如果您播放视频,它将显示在整个窗口中。但是我的 cms 会生成一个列表,如下所示:

<ul class="content-list">
<span class="k-infinite-load">
<li>
<span class="img-wrap">

<iframe class="k-custom-source" src="https://player.vimeo.com/video/141314866?username=1&assign_tag=1&tags=1&portrait=0&title=0&byline=0&autoplay=0&loop=0&color=d8d9da&api=1&player_id=koken_vimeo_49" width="1280" height="720" frameborder="0" title="Bootshaus Blackbox // CLUBBUSTERS 18.09.2015" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

            <span class="img-data">
                <!-- ......... -->
            </span>
</span>
</li>

我的问题是,当我使用 CSS 为 iFrame 设置动画和缩放时,它只会在其 span/li 中进行变形。 CSS:

Vimeo_Ani_IN {
    animation-fill-mode: forwards;  
    animation-name: VIMEO_IN;
    animation-duration: 1.5s;
}

.Vimeo_Ani_OUT {
     animation-name: VIMEO_OUT;
    animation-duration: 1.5s;
    animation-fill-mode: forwards;  
}

@keyframes VIMEO_IN {
    0%   {}
    100% {
        position:relative;
        top: 10px;
        height: 80%; /* fallback if needed */
        height: calc(100% - 90px);
        width: auto;
        position: absolute;
        top: 50%;
        left: 50%;
        width: 60%;
        height: 40%;
        transform: translate(-50%, -50%);
        -webkit-transform: translate(-50%, -50%);
        -moz-transform: translate(-50%, -50%);
        -o-transform: translate(-50%, -50%);
        -ms-transform: translate(-50%, -50%);
    }
}
@keyframes VIMEO_OUT {
    0%   {
        height: 100%;
        }
    100% {
    }
}

有没有人知道如何将其缩放到窗口,而不删除 CMS 给定结构并且只操作 iframe?当然应该是响应式的。

Greetz 并感谢所有回答的人。 马吕斯

【问题讨论】:

  • 尝试使用vh 作为视图高度,使用vw 作为视图宽度而不是百分比?即7vh 将是视图高度或窗口高度的 7%。

标签: javascript jquery html css iframe


【解决方案1】:

执行以下操作:

/* This you may already have, just check first */
html, body{
  margin:0;
  padding:0;
}


/*Be careful with this. I suggest finding a specific class or parent instead of ALL LIs */
li{list-style-type:none;}

/* This gives you the full screen window   */

span.img-wrap {
   display: flex;
   width: 100%;
   height:100%;
}

span.img-wrap iframe {
   width: 100%;
}

这是一个有效的DEMO

【讨论】:

  • 感谢 span.img-wrap iframe { width: 100%; } 工作! :)
  • 任何想法如何使 iframe 居中?
  • 如果有一个容器保存这个 iframe,将容器 div 居中,margin: 0 auto;这是一个有根据的猜测。如果不查看您的更多代码,我无法确定
  • 容器是 100%。但它们在 li 中,它们需要保持 24% 的宽度才能保持顺序......也许我会用边距做一个解决方法......谢谢你的回答
  • 没问题。玩弄 LI 的显示和宽度,看看你是否可以从那里控制它。但是要使项目居中,您需要给父项一个 text-align:center 或一个 margin:0 auto 到项目本身(在这种情况下为 iframe)
猜你喜欢
  • 1970-01-01
  • 2016-10-30
  • 1970-01-01
  • 2014-02-16
  • 2013-04-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-29
相关资源
最近更新 更多