Container Alignment 3 <div>?

I have three containers <div>, and I want to align them with one located to the left of the screen, one in the middle and one to the right. With equal space left between containers.

How can i do this?

+3
source share
2 answers

There are several ways to do this using float or layout. There was some kind of holy war between supporters of the table and supporters of the float. I lean a little towards the layout of the table, but both have their merits. I will be responsible for the table side:

<table style="table-layout:fixed;width:100%">
  <colgroup><col style="width:33%"/><col style="width:33%"/><col style="width:33%"/></colgroup>
  <tr>
    <td style="vertical-align:top">        
      <div style="border:1px solid red">
        column one with some long text that should wrap but still keep the column at 33%
      </div>
    </td>
    <td style="vertical-align:top">
      <div style="border:1px solid green">
        column two
      </div>
    </td>
    <td style="vertical-align:top">
      <div style="border:1px solid blue">
        column three
      </div>
    </td>
  </tr>
</table>

Here is an example: http://jsbin.com/axojo

+1
source

Source: https://habr.com/ru/post/1752677/


All Articles