Flexbox Not Centering Vertically in IE

前端 未结 10 675
自闭症患者
自闭症患者 2020-12-04 08:15

I have a simple web page with some Lipsum content that is centered on the page. The page works fine in Chrome and Firefox. If I reduce the size of the window, the content fi

10条回答
  •  醉酒成梦
    2020-12-04 08:37

    If you can define the parent's width and height, there's a simpler way to centralize the image without having to create a container for it.

    For some reason, if you define the min-width, IE will recognize max-width as well.

    This solution works for IE10+, Firefox and Chrome.

    div { display: -ms-flexbox; display: flex; -ms-flex-pack: center; justify-content: center; -ms-flex-align: center; align-items: center; border: 1px solid orange; width: 100px; height: 100px; } img{ min-width: 10%; max-width: 100%; min-height: 10%; max-height: 100%; }

    https://jsfiddle.net/HumbertoMendes/t13dzsmn/

提交回复
热议问题