CSS Flex布局-响应式居中布局

CSS Flex布局CSS display: flex1 个文件更新于 2026-04-06
html公开前 25 行,完整代码需登录
<style>
  .flex {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    background-color: #e8e8e8;
    min-height: 150px;
  }
  .flex-item {
    width: 100px;
    height: 100px;
    background-color: #2196F3;
    border: 1px solid #000;
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin: 5px;
  }
</style>
<div class="flex">
  <div class="flex-item">1</div>
  <div class="flex-item">2</div>
  <div class="flex-item">3</div>

登录后可以查看完整源码、在线编辑并实时预览运行效果。