search

Home  >  Q&A  >  body text

css3 - flex 父标签设置align-item:center,子元素flex:1,不起作用

flex 父标签设置align-item:center,子元素flex:1,不起作用,该元素内容为空的时候,宽度为0,如果父标签不设置align-item:center,子元素flex:1,是有效的,宽度会填充!大家有遇到过这个问题吗?

伊谢尔伦伊谢尔伦2865 days ago822

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-17 11:56:51

    In this case, it is recommended that you try setting width:auto;. After all, align-items:center; is used to cooperate with display:flex to center the child elements (vertical and horizontal). If the child elements are required to be centered, you need to set the child element. The width and height of the element

    reply
    0
  • Cancelreply