Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当垂直调整我的网站大小时,它会根据我的需要调整大小,但是当水平调整大小时,它不会填满屏幕。该站点名为 www.dinomoz.com,这是我用于背景视频的代码。
当窗口调整大小时,您需要查看它是否需要水平填充空间(并垂直裁剪),反之亦然。以下 jQuery 将执行此操作:
$(window).resize(function() { if ($('body').width() < $('body').height()) { $('video').css({height:'100%',width:'auto'}); } else { $('video').css({width:'100%',height:'auto'}); } });