如何让iframe,object,embed标签完美自适应视频宽度高度?下面的小编就给出对应的css控制代码。
.video {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
}
.video iframe,
.video object,
.video embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
html代码
<p class="video"> <iframe src="https://www.xxx.com" frameborder="0" allowfullscreen="allowfullscreen"></iframe> </p>
这样视频嵌入已经实现了宽高自适应了。
copy © 2025 星澜网络 All Rights Reserved