Combining rows and columns in flexbox

后端 未结 2 540
無奈伤痛
無奈伤痛 2021-01-22 06:19

I have three elements in an article: the photo, the categories and then the post info.

I am trying to figure out how to get the categories element to stack

2条回答
  •  日久生厌
    2021-01-22 07:02

    I'd put a wrapper div around the two things you want to stack. Then you can use flex to put that wrapper next to #1, and use flex inside that wrapper to stack #2 and #3.

    .flexbox {
        display: flex;
    }
    
    /* stack 1 next to .post-meta, containing 2 and 3 */
    .featured-image,
    .post-meta {
      flex: 1;
    }
    
    /* stack 2 and 3 inside .post-meta */
    .post-meta {
      display: inline-flex;
      flex-direction: column;
    }
    
    
    /* these styles are mostly for demo purposes;
     * adjust or remove as needed */
    
    .post-categories, 
    .post-info {
      padding: 10px;
      list-style: none;
      margin: 0;
    }
    
    .featured-image {
      background-color: skyblue;
     }
    
    .post-categories { background: #ccc; }
    .post-info { background: #ffffd; }

提交回复
热议问题