灵活的html5 video标签(demo)
使用html5的video,可以通过设置max-width:100%让他变得灵活。前面的介绍中,已经提到他不适用于常用的iframe和object中的内嵌代码。
video {
max-width: 100%;
height: auto;
} 灵活的 Object & Iframe 内嵌视频
这个技巧相当简单,你需要为video添加一个<p>容器,并且将p的padding-bottom属性值设置在50%到60%之间。然后设置子元素(ifame或者object)的width和height为100%,并且使用绝对定位。这样会迫使内嵌对象自动扩充到最大。
CSS.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
} HTML <p class="video-container">
<iframe src="http://player.vimeo测试数据/video/6284199?title=0&byline=0&portrait=0" width="800" height="450" frameborder="0"></iframe></p> 在固定宽度下实现灵活性
如果限制了视频的宽度,那么我们需要一个额外的<p>容器包裹video,并为p设置固定宽度和max-width:100%。
CSS.video-wrapper {
width: 600px;
max-width: 100%;
} HTML <p class="video-wrapper">
<p class="video-container">
<iframe src="http://player.vimeo测试数据/video/6284199?title=0&byline=0&portrait=0" width="800" height="450" frameborder="0"></iframe>
</p>
<!-- /video --></p><!-- /video-wrapper --> 兼容性
这个技巧支持所有的浏览器,包括:Chrome, Safari, Firefox, Internet Explorer, Opera, iPhone 和 iPad。
以上就是HTML5实践-使用CSS实现弹性视频的代码分享的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于HTML5实践-使用CSS实现弹性视频的代码分享的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did41396