【发布时间】:2019-04-17 04:37:13
【问题描述】:
目前,我有 3 个 div,左中和右,我希望在中心部分有一个 div(通知)并且位置固定,以便在滚动时始终保持在该位置。并且当改变浏览器大小时,通知仍然会停留在中心 div 内并相应地改变大小。目前,当我使用位置:固定时,它使用视口而不是中心 div。
我想要的输出将是通知蓝条相对于中心 div 的大小相同,具有左右填充,并且当减小浏览器的大小时,蓝条仍然停留在中心 div 内。
当前显示: 预期展示:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-lg-2" style="background-color: red; height: 1000px">Test</div>
<div class="col-lg-7" style="background-color: yellow; height: 1000px">
<div style="display: block; position: relative; z-index: 9999; width: 100%; padding-left: 5; top: 50"><div style="position: fixed; background-color: blue; ">Notification</div></div>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
Test<br>
</div>
<div class="col-lg-3" style="background-color: green; height: 1000px">Test3</div>
</div>
</div>
【问题讨论】:
-
如此处的 sn-ps 预览中所示(一旦将其展开到整页),它更像是预期而不是“当前”结果。 (火狐。)