您可以应用样式text-align:center;到您的容器,并将.blocks显示为inline-block元素:
.container {
width: 70%;
background: #eee;
margin: 10px auto;
position: relative;
text-align:center;
}
.block {
background: green;
height: 100px;
width: 100px;
display:inline-block;
margin: 10px;
}
1. name of the company
2. name of the company
3. name of the company
4. name of the company
5. name of the company
6. name of the company
7. name of the company
8. name of the company
注意我已注释掉了< div>之间的空格。因为元素现在显示为内联,所以您的空格将被确认。这是one of many ways“打空间”。