Ignore flex container children but not grandchildren

前端 未结 2 839
滥情空心
滥情空心 2020-12-22 04:01

I have a simple flex element with some children, something like this:

2条回答
  •  心在旅途
    2020-12-22 04:22

    Use display:contents (https://css-tricks.com/get-ready-for-display-contents/) but pay attention to the support (https://caniuse.com/#feat=css-display-contents)

    .container {
      display: flex;
      flex-wrap: wrap;
    }
    
    .container div.flex-box {
      width: 200px;
      margin: 20px;
      padding: 20px;
      font-size: 40px;
      border: 1px solid;
    }
    
    .subcontainer {
      display: contents
    }
    one
    two
    three
    four
    five
    six

提交回复
热议问题