How to display hr horizontally with flex?

后端 未结 2 988
旧巷少年郎
旧巷少年郎 2021-01-11 20:07

When using flexbox for styling, if the parent container is set to display: flex it will cause the


to be displayed vertically instead o
2条回答
  •  有刺的猬
    2021-01-11 20:25

    Use flex-grow: 1 or width: 100% so it will grow to match the width of the parent. You probably want to use that in combination with flex-wrap: wrap on .container if you plan on putting more flex children in .container

    .container {
      display: flex;
      flex: 1;
    }
    
    hr {
      flex-grow: 1;
      /* width: 100%; */ /* or this */
    }

提交回复
热议问题