align list element horizontally code example
Example 1: how to align elements horizontally in css
.row {
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
}
.block {
width: 100px;
}
Example 2: 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
{
display: flex;
align-items: stretch;
justify-content: space-between;
width: 100%;
}
ul.navbar-items li
{
padding: 10px;
}