0

http://jsfiddle.net/c3tGR/

I want these elements to be centered, but with variable number of items per row based on the width of the window.. so on a wide window you'd have all 5 side by side, centered; on a narrower one you'd have 3 on the first row and 2 on the second, but each row is centered.

Is there any way to do this with CSS?

4

2 回答 2

1

添加一个父块并给它text-align: centerjsfiddle

于 2012-06-28T19:55:21.783 回答
1

把这个放在父母身上

text-align: center;

http://jsfiddle.net/c3tGR/2/

于 2012-06-28T19:55:22.437 回答