慕桂英4014372
bobince的回答会让你知道在哪种情况下“身高:XX%;” 将会或不会工作。如果要创建具有设定比率的元素(高度:它自身宽度的百分比),最好的方法是使用有效设置高度padding-bottom。方形示例:
position: relative;
height: 0;
padding-bottom: 100%; /* of parent width */
}
.square-content {
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
}方形容器将由填充物制成,内容将扩展以填充容器。2009年关于这个主题的长篇文章:http://alistapart.com/article/creating-intrinsic-ratios-for-video