我想将两个 div 并排放置。第二个居中,第一个在第二个左侧并粘贴/固定。因为最后一个条件the existing solution不起作用(属性 position
已经用于两个 div)。我该如何解决这个问题?
最佳答案
像这样:
.container {
display: flex;
height:100%;
}
.left {
margin-left: auto;
width: 0;
display: flex;
justify-content: flex-end;
}
.centered {
margin-right:auto;
padding:5px;
background:green;
height:100%;
}
.left span {
position:fixed;
white-space: nowrap;
padding:5px;
background:red;
}
body {
height:200vh;
}
<div class='container'>
<div class='left'><span> some content</span></div>
<div class='centered'>centered</div>
</div>
关于html - 两个 div 并排 : first sticked and the second centered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52221686/