gpt4 book ai didi

html - CSS div 大小高度自动调整

转载 作者:行者123 更新时间:2023-11-28 03:03:55 24 4
gpt4 key购买 nike

我有一个包含 videoWrapper 的 div 元素。我想让它做的是当我缩小浏览器的屏幕时能够自动调整大小。它适用于宽度,因为我可以为其设置一个 %。但是我必须为像素设置一个固定值。所以现在它会自动调整宽度而不是高度,它始终保持不变。

这是我为div 使用的css 样式

height: auto;
height: 700px;
width: 70%;
border-style: solid;
border-color: red;

最佳答案

像这样的东西应该可以工作

<div class="videoWrapper">

<iframe width="560" height="349" src="" frameborder="0" allowfullscreen></iframe>

</div>

.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
}
.videoWrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

关于html - CSS div 大小高度自动调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33403051/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com