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.
我有一个固定宽度和高度的块元素 DIV。我为此 DIV 使用了背景图像。我们可以使用百分比 (%) 动态更改宽度。
是否可以获得该宽度的比例高度?如果是这样,我们怎样才能做到这一点?
这是一个例子:
100px 宽度 #div 有高度:20px; 所以,50px 宽度 #div 有 height:10px;
我怎样才能做到这一点?
您可以将 height: 0 与百分比填充顶部一起使用。
查看http://webdesignerwall.com/tutorials/css-elastic-videos