我有一個容器和兒童元素。容器的位置固定在10%的高度。每個子元素必須有100%的高度和寬度等於它的高度 - 當我添加我的容器水平擴展而不是垂直時,這會變得更加複雜。我想問一下,如果這可以使用CSS,因爲使用JavaScript可以很容易地實現,但我不得不傾聽窗口大小,這是一個痛苦,我想避免這種情況。寬度等於高度
.container {
width: 200px;
height: 10%;
border: solid 1px black;
position: fixed;
top: 0;
left: 0;
white-space: nowrap;
overflow: auto;
}
.container > div {
display: inline-block;
height: 100%;
width: 50px;
border-radius: 50%;
border: solid 1px black;
}
https://jsfiddle.net/fdtajx3k/1/
試試這個:http://www.endocreative.com/flexbox-circle-responsive-elements/ – JackHasaKeyboard