您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

为什么这些弹性物品没有包装?

为什么这些弹性物品没有包装?

嵌套容器中的伸缩项目按 调整大小。@H_502_1@

.col-one{
  width: 40%;
  height: 100px;
  border: 1px solid lightgreen;
}
.col-two{
  width: 40%;
  height: 100px;
  border: 1px solid red;
}

由于百分比长度基于父级的长度,因此 没有理由进行包装 。它们将始终是父级的40%,即使父级的宽度为1%。@H_502_1@

如果您使用其他长度单位,例如pxem,它们将自动换行。@H_502_1@

 .container {

   display: flex;

   justify-content: center;

   align-items: center;

   flex-flow: row wrap;

   height: 100vh;

 }



 .sub-con {

   flex: 1;  /* for demo only */

   align-content: flex-start; /* for demo only */

   margin-right: 50px;

   margin-left: 50px;

   height: 500px;

   background-color: #fff;

   display: flex;

   justify-content: center;

   flex-flow: row wrap;

 }



 .col-one {

   width: 200px;

   height: 100px;

   border: 1px solid lightgreen;

 }



 .col-two {

   width: 200px;

   height: 100px;

   border: 1px solid red;

 }


<div class="container">

  <div class="sub-con">

    <div class="col-one"></div>

    <div class="col-two"></div>

  </div>

</div>
其他 2022/1/1 18:15:04 有594人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶