如何居中放置.container,以使小屏幕上的项目保留在原处,.container居中。
我的例子https://codepen.io/zakhar_coder/pen/QWbQxdE?editors=1100
.container {
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.item {
width: 370px;
height: 250px;
background-color: #333;
margin: 0 30px 30px 0;
}
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
>
this option of placing elements is not suitable for me
如何居中放置.container,以便小屏幕上的项目保留下来,.container居中。我的示例https://codepen.io/zakhar_coder/pen/QWbQxdE?editors=1100 .container {display:...
您不需要那么做。给容器加max-width
并将其宽度强制为100%。之后,您可以使用margin: 0 auto;
将其居中。