css - Chrome上iframe显示异常(Firefox正常)

标签 css cross-browser

关于 my page ,顶部居中的嵌入式 YouTube 视频 (iframe) 填满了 Firefox 上的整个响应容器,但由于某种原因,它显示得小得多,并且仅在 Chrome 上的容器的上半部分显示:

enter image description here

HTML:

<div class='product_frame_wrap'>
    <div class='product_frame'>
        <div class='product_frame_image_vid'>
            <iframe>...</iframe>
        </div>
    </div>
</div>

CSS:

.product_frame_wrap {
    margin: 0 auto;
    max-width: 600px;
    position: relative;
    width: 100%;
}
.product_frame {
    background: rgba(0, 0, 0, 0) url("images/frame.png") no-repeat scroll 50% 50% / contain ;
    padding-bottom: 75%;
    position: relative;
}
.product_frame_image_vid {
    bottom: 0;
    left: 0;
    padding-top: 5%;
    position: absolute;
    right: 0;
    top: 0;
}
.product_frame_image_vid iframe {
    height: 100% !important;
    width: 100% !important;
}

最佳答案

如果您查找特定于浏览器的 css,您会发现 hacks。下面的代码只会影响 chrome 浏览器。当您将 iframe 的高度设置为 200% 时,它似乎在 chrome 中正确填充。

将以下代码片段添加到您的 css 应该可以解决问题:

@media screen and (-webkit-min-device-pixel-ratio:0) { 
    .product_frame_image_vid iframe { height:200%; } 
}

关于css - Chrome上iframe显示异常(Firefox正常),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34323437/

相关文章:

JQuery,由于图像内容错误识别了 div 的高度

javascript - 如何将变量发送到 php 并转到一个链接中的 div?

css - 如何知道 Twitter Bootstrap 处于哪种状态/格式?

html - Background_position 不工作

google-chrome - 将顶级域指向 url 的最佳方法是什么?

html - Doctype 搞乱了 CSS 字体样式?

html - 有没有办法使用CSS来突出关键字?

java - 将 JSP 文件包含在另一个 JSP 文件中时出现 iFrame 浏览器问题

css - 浏览器对自定义 CSS3 单选按钮的支持

html - IE 7/8 中文本输入的文本缩进替代方案