Flexbox with Unordered list
You need to apply the flex properties to the <ul>
ul {
display: flex;
flex-direction: row; <-- not needed as this is the default behavior
flex-wrap: wrap;
}
Putting the properties on the <div>
tells it to display the <ul>
in flex, not <li>
.
Based on your markup, note that the <li>
elements are the child of <ul>
, not the .example
division element.
<div class="example">
<ul>
<li>1</li>
</ul>
</div>
Since the immediate parent of the <li>
elements are <ul>
, use the flex
properties on the <ul>
that is wrapping around the multiple <li>
elements, instead of the outer <div>
element:
.example {
width: 50%;
border: 1px solid #000;
margin: 1em 0;
ul {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
padding-left: 0;
}
li {
list-style: none;
display: inline-block;
width: calc(100% / 3);
height: 120px;
text-align: center;
}
}
http://codepen.io/anon/pen/NGPBbg