Here is a CSS3 method for aligning divs horizontally inside another div.
#container {_x000D_
display: flex; /* establish flex container */_x000D_
flex-direction: row; /* default value; can be omitted */_x000D_
flex-wrap: nowrap; /* default value; can be omitted */_x000D_
justify-content: space-between; /* switched from default (flex-start, see below) */_x000D_
background-color: lightyellow;_x000D_
}_x000D_
#container > div {_x000D_
width: 100px;_x000D_
height: 100px;_x000D_
border: 2px dashed red;_x000D_
}
_x000D_
<div id="container">_x000D_
<div></div>_x000D_
<div></div>_x000D_
<div></div>_x000D_
</div>
_x000D_
The justify-content
property takes five values:
flex-start
(default)flex-end
center
space-between
space-around
In all cases, the three divs are on the same line. For a description of each value see: https://stackoverflow.com/a/33856609/3597276
Benefits of flexbox:
To learn more about flexbox visit:
Browser support: Flexbox is supported by all major browsers, except IE < 10. Some recent browser versions, such as Safari 8 and IE10, require vendor prefixes. For a quick way to add prefixes use Autoprefixer. More details in this answer.