Centering 2 Divs inside another vertically

前端 未结 2 800
挽巷
挽巷 2021-02-14 00:45

I have 2 divs that I want to centre vertically inside another div. At the moment I have:

http://jsfiddle.net/5vpA3/1/

Now I understand what is going on here, but

2条回答
  •  忘掉有多难
    2021-02-14 01:01

    Flexbox solution to center vertically:

    #container {
        display: flex;
        align-items: center;
    }
    

    OP's original fiddle modified: http://jsfiddle.net/o3pmyb8c/

    If you would like to also center horizontally you can add justify-content: center;

提交回复
热议问题