CSS flexbox vertically/horizontally center image WITHOUT explicitely defining parent height

后端 未结 2 1199
终归单人心
终归单人心 2020-12-08 04:06

With only the parent div and the child img elements as demonstrated below how do I vertically and horizontally center the

2条回答
  •  时光说笑
    2020-12-08 04:33

    Without explicitly defining the height I determined I need to apply the flex value to the parent and grandparent div elements...

    No, he'll be an engineer.

    If you're using a single element (e.g. dead-centered text in a single flex element) use the following:

    align-items: center;
    display: flex;
    justify-content: center;
    

提交回复
热议问题