當高度爲父div的百分比時,是否可以用css或js設置元素的寬度以匹配其高度。如果瀏覽器窗口調整大小,則子div也需要更改大小。寬度等於動態高度平方
例
body, html {height: 100%}
.parent {height: 100%; width: 960px;}
.child {
height: 50%;
width: same as height; /* but not 50% of 960px, so that the child div is square*/
}
我想實現這樣的事情,但寬度,而不是高度。 Height equal to dynamic width (CSS fluid layout)
在此先感謝:-)
的Javascript,我的朋友。 –