首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当这些子容器包装时,如何使它们之间的空间更少?

当这些子容器包装时,如何使它们之间的空间更少?
EN

Stack Overflow用户
提问于 2020-08-21 18:49:37
回答 1查看 32关注 0票数 0

这是我的孩子div的样子,我试图让他们在包装时有更少的空间。

我认为问题在媒体查询中。

代码语言:javascript
复制
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 10px;
  width: 100%;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  /* added the line above remove if erros */
}

.container-2 {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background-color: red;
  align-items: center;
}

.item {
  margin: 2% 1%;
  width: 95%;
  height: 12%;
  background-color: yellow;
  border: solid black;
  border-radius: 1% 1%;
}


/* Extra large devices (large laptops and desktops, 1200px and up) */

@media only screen and (min-width: 1200px) {
  .container-1 img {
    width: 50%;
    height: 100%;
  }
  .container-2 {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .item {
    margin: 2% 1%;
    width: 25%;
    height: 12%;
    background-color: yellow;
    border: solid black;
    border-radius: 1% 1%;
  }
}
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="./css/menu.css">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Menu | Andy's House</title>
</head>

<body>


  <div class="container-2">

    <div class="item">

    </div>
    <div class="item">

    </div>
    <div class="item">

    </div>
    <div class="item">

    </div>
    <div class="item">

    </div>
    <div class="item">

    </div>
    <div class="item">

    </div>




  </div>


  </div>

</body>

</html>

我想让他们之间的空间更少。如果有人知道如何,这将是非常感谢!如果你看不出来的话,我就是个菜鸟。所以,我很抱歉:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-21 19:05:22

问题不在于媒体查询。我会把集装箱高度改为自动。如下所示:

代码语言:javascript
复制
.container-2 {
display: flex;
flex-direction: column;

width: 100%;
height: auto;
background-color: red;
align-items: center;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63528535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档