codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › Flexbox

Flexbox

Lay out items in a row or column with ease.

Set display: flex on a parent. Then use justify-content (main axis), align-items (cross axis) and gap.

Example code

<style>
  .row { display: flex; justify-content: space-between;
         align-items: center; gap: 10px; height: 120px; background: #eee; }
  .row div { background: coral; padding: 14px; color: #fff; }
</style>
<div class="row"><div>One</div><div>Two</div><div>Three</div></div>

Run this code in the online editor

← The box modelResponsive design →