将多个div对齐(固定)

时间:2018-02-12 13:58:07

标签: javascript html css alignment

我想在自定义MainDiv中对齐多个(在本例中为3个)div,以获得如下结果: img



<div style="position: fixed; width:100%; height: 12%; left:0%; top: 0%; background: black">
  <div style="color: white; left: 5%; margin-top: 5%; position: fixed; font-size: 10px">INFORMATION A</div>
  <div style="color: white; margin:0 auto; margin-top: 5%; display: table; font-size: 10px">INFORMATION B</div>
  <div style="color: white; right: 5%; margin-top: 5%; position: fixed; font-size: 10px">INFORMATION C</div>
</div>
&#13;
&#13;
&#13;

但是这段代码似乎没有效果,因为这是我得到的结果:img 2

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

你可以使用flex-layouting

<div style="position: fixed; width:100%; height: 50%; left:0%; top: 0%; background: black; display: flex; justify-content: space-between;">                           
  <div style="color: white; left: 5%; margin-top: 5%; position: fixed; font-size: 10px">INFORMATION A</div>
  <div style="color: white; margin:0 auto; margin-top: 5%; display: table; font-size: 10px">INFORMATION B</div>
  <div style="color: white; right: 5%; margin-top: 5%; position: fixed; font-size: 10px">INFORMATION C</div>
</div>