A quick introduction to the CSS Flexbox properties, how they work and what they do.
Flexbox
Use Flexbox to get things beside other things
Inline-block will always have a little space between—where flexboxes can touch.
Many of the flexbox properties are applied to the parent element, but affect the child elements.
This is different from many other CSS properties that directly affect the selected element.
display: flex
flex-direction: row
justify-contents
align-items
<div class="columns"> <div class="col">Column 1</div> <div class="col">Column 2</div> </div>
.columns { display: flex; flex-direction: row; } .col { background-color: yellow; }
.columns { display: flex; flex-direction: row; justify-content: space-between; } .col { background-color: yellow; }
.columns { display: flex; flex-direction: row; } .col { width: 50%; background-color: yellow; }
<div class="columns"> <div class="col">Column 1</div> <div class="col"> <h2>Column 2</h2> </div> </div>
.columns { display: flex; flex-direction: row; justify-content: space-around; align-items: center; } .col { background-color: yellow; }