【问题标题】:can't resize containers with youtube and responsive无法使用 youtube 和响应式调整容器的大小
【发布时间】:2015-06-20 02:13:54
【问题描述】:

http://m.mits.remax.ca/ 上面的链接,youtube和标题之间有很大的差距。我试着到处寻找,仍然找不到问题所在。

起初,我使用普通的 youtube iframe 并将视频居中,但我发现它没有响应,所以我找到了一些在线 css 并添加了它,效果很好,但我尝试将视频制作为 75% 而不是 100%但出现了 75% 的差距。

有人可以帮帮我吗?

我找到并使用的css是

.video-container {
        position: relative;
        padding-bottom: 56.25%;
        padding-top: 25px;
        height: 0;
    }

    .video-container iframe,
    .video-container object,
    .video-container embed {
        position: absolute;
        top: 0;
        left: 12.5%;
        width: 75%!important;
        height: 75%!important;
    }

【问题讨论】:

    标签: html css youtube containers


    【解决方案1】:

    height: 75%; 在您的视频中造成视频和标题之间的巨大差距。您可以对其进行调整,例如:100%。如果要调整高度,请不要将视频高度设置为75%,而是在.video-container 上设置padding-bottom。

    编辑

    我刚试过这个:

    .video-container {
      padding-bottom: 37.25%;
      margin-bottom: 30px;
    }
    .video-container iframe {
      height: 100% !important;
    }
    

    这就是我得到的http://take.ms/Zh8eq 让我知道这是否是您正在寻找的。​​p>

    应用你的css后我的css是什么样子的

    .video-container {
       position: relative;
       padding-bottom: 37.25%;
       padding-top: 25px;
       height: 0;
       margin-bottom: 30px;
    }
    .video-container iframe,
    .video-container object,
    .video-container embed {
      position: absolute;
      top: 0;
      left: 12.5%;
      width: 75%!important;
      height: 100%!important;
    }
    

    【讨论】:

    • 我在发帖之前确实尝试过,但这只会让事情变得更糟:(
    • 我的意思是视频仍然存在并且视频缩小了,我会看到两侧是黑色的,但差距仍然存在。我什至也试过去掉填充物
    • 啊!为什么我没有想到尝试 margin-bottom 而不是继续尝试填充!让我试试……
    • 不知何故 margin-bottom 对我不起作用,如果我只是在那里使用你的 css 并删除前一个,这就是我得到的 https://remax.imprev.net/omc/viewImage.ipv?guid=a56844a2-b0e4-4ea2-ba14-8dd451c27149&fullsize=true 并且我尝试同时使用 chrome 和 firefox 查看:(
    • 不需要删除之前的样式。只需在上面应用我的补丁即可。
    猜你喜欢
    • 2018-11-26
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多