按
中心我的意思是中心立方体位于视口中心(并在调整视口大小时停留在此中心),并且如有必要,从左和右切除其余的固定元素。
这必须是老式的,即no flexbox。
#element {
width: 120%;
height: 200px;
position: fixed;
left: 0;
top: 0;
border: 2px dashed #ec6161;
}
#children {
display: flex;
justify-content: space-around;
align-items: center;
height: 100%;
}
.child {
width: 50px;
height: 50px;
border: 2px dashed #888;
postion: absolute;
}
<div id="element">
<div id="children">
<div class="child left"></div>
<div class="child center"></div>
<div class="child right"></div>
</div>
</div>
#element {
width: 120%;
height: 200px;
position: fixed;
left: 0;
top: 0;
border: 2px dashed #ec6161;
margin-left: -10%;
}
您可以将margin-left: -10%
添加到您的#element组件中