【发布时间】:2018-02-12 14:21:16
【问题描述】:
我想创建一个如下所示的元素:
这是我目前得到的代码,但 Id 似乎不是这样工作的:
<div style="position: fixed; width:100%; height: 22%; left:0%; top: 0%; background: #795547; box-shadow: 0px 0px 2px 0px #795547; display: flex; justify-content: space-between;">
<div style="color: white; left: 3%; margin-top: 3%; position: fixed; font-size: 11px">TRUE HEADING</div>
<div style="color: white; display: table; margin:0 auto; margin-top: 3%; font-size: 11px">MAGNETIC HEADING</div>
<div style="top: 0%; color: white; right: 3%; margin-top: 3%; position: fixed; font-size: 11px">MAGNETIC FIELD</div>
<div style="position: fixed; left: 3%; margin-top: 2%; color: white; font-size: 14px">135° SE</div>
<div style="position: fixed; margin-top: 2%; margin: 0 auto; color: white; font-size: 14px">123° SE</div>
<div style="position: fixed; right: 2%; margin-top: 2%; color: white; font-size: 14px">49 uT</div>
</div>
如何编辑我的代码以获得上述结果?
【问题讨论】:
-
你为什么到处都使用固定位置?你应该从头开始使用三个块和 flexbox
-
能否请您添加一个小例子sn-p? @Axnyff
-
@JaneDeverly 使用 position fixed 会使元素即使在滚动时也会卡在原来的位置,所以如果添加更多元素,则会妨碍其他元素
标签: javascript html css styles