Flexbox 可以这样做:
http://jsfiddle.net/vUSmV/2/
.flavours {
min-height: 10em;
display: -webkit-box;
display: -moz-box;
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-moz-box-pack: center;
-webkit-flex-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-flex-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
将 Flexbox 与可换行的内联列表项一起使用(请注意,换行会降低浏览器对 Chrome、Opera 和 IE10 的支持):
http://jsfiddle.net/vUSmV/4/
.flavours {
min-height: 10em;
border: 1px solid;
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-flex-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-flex-line-pack: center;
-ms-flex-line-pack: center;
-webkit-align-content: center;
align-content: center;
-webkit-flex-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
@supports (flex-wrap: wrap) {
.flavours {
display: flex;
}
}
.flavours li {
margin: .5em 1em;
}
或者您可以将列表转换为表格单元格元素:
http://jsfiddle.net/vUSmV/1/
.flavours {
min-height: 10em;
display: table-cell;
vertical-align: middle;
}