gpt4 book ai didi

javascript - 宽度等于动态高度平方

转载 作者:行者123 更新时间:2023-11-29 15:42:24 24 4
gpt4 key购买 nike

<分区>

当高度是父 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)

提前致谢:-)

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