花式盒子 - Youtube嵌入100%,同时保持纵横比

Fancybox - Youtube Embed 100% while maintaining the Aspect Ratio

本文关键字:盒子 Youtube 100% 嵌入      更新时间:2023-09-26

我想知道是否有办法在花式框中打开嵌入式 Youtube 视频并占据一定比例的宽度,比如 100% 或尽可能大,同时保留其中包含的视频的纵横比。

我有:

$('.fancybox').fancybox({
        helpers: {
            media: {},
            overlay : {
                css : {
                    'background' : 'rgba(230, 230, 215, 0.95)'
                }
            }
        },
        padding: 0,
        margin: 30,
        width: '90%',
        aspectRatio : true,
        autoSize: false,
        arrows: false,
        closeBtn: false
    });

看起来可以使用一些CSS和/或jQuery。您将使用嵌入代码,而不是使用Fancybox代码。查看这篇文章: http://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php