align flex items horizontally code example

Example 1: css flex center

display: flex;
align-items: center;
justify-content: center;

Example 2: flex align children to side

flex-direction: column;
align-items: flex-start; //left
align-items: center; //center
align-items: flex-end; //right

Example 3: html list items horizontally with flexbox

for example: 
(html)
<ul class="navbar-items">
	<li> <a href="#start">Start</a> </li>
    <li> <a href="#profile">Profile</a> </li>
    <li> <a href="#projects">Projects</a> </li>
    <li> <a href="#info">Info</a> </li>
</ul>

(css)
ul.navbar-items /* Important part */
{
    display: flex;
    align-items: stretch; 
    justify-content: space-between;
    width: 100%; /* play with this number to get spacings correct */
}

ul.navbar-items li /* Extra part, to style each item */
{
    padding: 10px;
}

Tags:

Misc Example