【发布时间】:2020-11-22 19:09:39
【问题描述】:
我有一个位置固定的 div。它下面有一个 div,我很难定位。这是我的 JSX 标记:
<div>
<div style={topBar}>
REAL TIME AIR QUALITY INDEX
</div>
<div style={infoDiv}>
Lorem Ipsum
</div>
</div>
这是我的样式:
const topBar = {
width: '100%',
background: 'rgba(255,255,255,0.1)',
position: 'fixed',
padding: '10px',
textAlign: 'center',
fontWeight: '800',
background: 'yellow'
}
const infoDiv = {
background: 'red',
marginTop: '100px'
}
我的问题是,topBar 不是固定在顶部,infoDiv 下降 100 像素,而是 infoDiv 保持在顶部,topBar 下降。
这是一张图片:
【问题讨论】: