I think you want something like the following.
html, body {_x000D_
height: 100%;_x000D_
}_x000D_
body {_x000D_
margin: 0;_x000D_
}_x000D_
.flex-container {_x000D_
height: 100%;_x000D_
padding: 0;_x000D_
margin: 0;_x000D_
display: -webkit-box;_x000D_
display: -moz-box;_x000D_
display: -ms-flexbox;_x000D_
display: -webkit-flex;_x000D_
display: flex;_x000D_
align-items: center;_x000D_
justify-content: center;_x000D_
}_x000D_
.row {_x000D_
width: auto;_x000D_
border: 1px solid blue;_x000D_
}_x000D_
.flex-item {_x000D_
background-color: tomato;_x000D_
padding: 5px;_x000D_
width: 20px;_x000D_
height: 20px;_x000D_
margin: 10px;_x000D_
line-height: 20px;_x000D_
color: white;_x000D_
font-weight: bold;_x000D_
font-size: 2em;_x000D_
text-align: center;_x000D_
}
_x000D_
<div class="flex-container">_x000D_
<div class="row"> _x000D_
<div class="flex-item">1</div>_x000D_
<div class="flex-item">2</div>_x000D_
<div class="flex-item">3</div>_x000D_
<div class="flex-item">4</div>_x000D_
</div>_x000D_
</div>
_x000D_
See demo at: http://jsfiddle.net/audetwebdesign/tFscL/
Your .flex-item
elements should be block level (div
instead of span
) if you want the height and top/bottom padding to work properly.
Also, on .row
, set the width to auto
instead of 100%
.
Your .flex-container
properties are fine.
If you want the .row
to be centered vertically in the view port, assign 100% height to html
and body
, and also zero out the body
margins.
Note that .flex-container
needs a height to see the vertical alignment effect, otherwise, the container computes the minimum height needed to enclose the content, which is less than the view port height in this example.
Footnote:
The flex-flow
, flex-direction
, flex-wrap
properties could have made this design easier to implement. I think that the .row
container is not needed unless you want to add some styling around the elements (background image, borders and so on).
A useful resource is: http://demo.agektmr.com/flexbox/