如何让div忽略其父母的显示:flex

用户名

我有一个父divdisplay: flex我希望其中一个孩子div可以忽略这一点。

例如,我想要这样的东西:

儿童div1

儿童div2,儿童div3,儿童div4

我希望第一个Child div1位于顶部,而行中没有任何其他元素。我知道,只要将孩子div1移到其父级之外,我就可以实现这一目标,但是很高兴知道另一种方式。

/* Parent div */
.boxContainer {
    display: flex;
    height: 500px;
    width: 100%;
}

/* Child div1 */
.headerBox {
    height: 100px;
}
 /* more child div */
.imgBox {
    margin-top: 100px;
    height: 375px;
    width: 375px;
}
或Drori

采取项目完全不在Flexbox的流量,你可以将它的位置absolute,然后移动它,你想topleft等...

设置position: absolute的孩子,position: relative对家长:

.boxContainer {
  /** Parent div **/
  position: relative;
  display: flex;
  height: 500px;
  width: 100%;
}

.headerBox {
  /** Child div1 **/
  position: absolute;
  top: -50px;
  /** move it up **/
  height: 100px;
}

.imgBox {
  /** more child div **/
  margin-top: 100px;
  height: 375px;
  width: 375px;
}

如果只需要分开第一项,则可以使用弹性包装,并在第一项margin-right: 100%上进行设置

/* Parent div */

.boxContainer {
  display: flex;
  height: 200px; /** I've changed the dimensions to fit the demo windows **/
  width: 100%;
  flex-wrap: wrap;
}


/* Child div1 */

.headerBox {
  margin-right: 100%;
  height: 100px;
}


/* more child div */

.imgBox {
  height: 75px;
  /** I've changed the dimensions to fit the demo windows **/
  width: 75px;
  /** I've changed the dimensions to fit the demo windows **/
}
<div class="boxContainer">
  <div class="headerBox">headerBox</div>

  <div class="imgBox">imgBox</div>

  <div class="imgBox">imgBox</div>

  <div class="imgBox">imgBox</div>

  <div class="imgBox">imgBox</div>

  <div class="imgBox">imgBox</div>

  <div class="imgBox">imgBox</div>

  <div class="imgBox">imgBox</div>

  <div class="imgBox">imgBox</div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Bootstrap中使用d-flex时如何获取其父母的div高度

如何忽略父母的div中心位置

如何将可调整大小的子div适合其父母

ReactJS-孩子如何找到其父母?

如何制作 Flex div 并将其(图像)子项包含在其父项中?

如何使用 flex 显示每行的最大 div?

如何递归地找到资源在其父母中的掩码?

ReactJS-孩子如何访问其父母的道具?

如何仅预加载其父母已激活的模块?

如何在多个插槽与其父母之间共享状态

让孩子修改其父母

如何在其父DIV区域之外显示按钮边框?

如何使用CSS在其父<div>的鼠标悬停时显示<p>元素?

如何在div的右侧显示图像而不破坏flex布局?

如何使用flex以砌体样式正确显示我的div?

需要将不同高度的菜单放置在其父母div的垂直居中位置

如何使子元素/组件忽略其父元素的大小?

如何设置元素样式以忽略其父元素的填充?

如何使 div 填充其父级的宽度?

如何在Google App Engine的ManyToOne端按其父母过滤实体

如何更改Qwidget的背景颜色,而不考虑其父母的背景颜色

悬停其父母时如何更改子元素的不透明度

显示 flex 不拉伸 div

如何在模板中显示父母的孩子?

如何强制div被忽略?

确定父母的大小时如何忽略某个元素

如何在CSS中忽略父母的宽度限制

当他的父母移动时如何让克隆忽略移动输入

如何让孩子在flex中填充父母的所有可用高度