0

I'd like to align multiple (in this case 3) divs in a custom MainDiv to get a result like this: 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>

But this code doesn't seem to be working because this is the result I'm getting: img 2


How can I fix this?

Andrew Bone
  • 7,092
  • 2
  • 18
  • 33

1 Answers1

0

you can use 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>
FrontTheMachine
  • 526
  • 3
  • 14
  • flex laout with position fixed ? – Temani Afif Feb 12 '18 at 14:01
  • yes? the flex-layout change the behaviour of its content to be flexible, doesn't care about being fixed positioned. – FrontTheMachine Feb 12 '18 at 14:04
  • really ?? read this : Fixed : The element *is removed from the normal document flow*; no space is created for the element in the page layout. – Temani Afif Feb 12 '18 at 14:06
  • @kurtwellitis please don't consider bad hack like this ... adding flex work in this case simply because one of the element is not fixed and thus belong to the flow ... so it was changed to flex item and is no more a block item ! – Temani Afif Feb 12 '18 at 14:08
  • Your right @TemaniAfif –  Feb 12 '18 at 14:09
  • @kurtwellitis add `top: 0;` in the initial code to the third div ... or re-consider all your code to use proper way of flex or any other technique and don't do this ! – Temani Afif Feb 12 '18 at 14:09