Align a div to center

后端 未结 14 2096
别跟我提以往
别跟我提以往 2020-12-02 13:20

I want to float a div to center. Is it possible? text-align: center is not working in IE.

14条回答
  •  隐瞒了意图╮
    2020-12-02 13:26

    floating divs to center "works" with the combination of display:inline-block and text-align:center.

    Try changing width of the outer div by resizing the window of this jsfiddle

    one
    two
    three
    four
    five

    and the css:

    .outer {
        text-align:center;
        width: 50%;
        background-color:lightgray;
    }
    
    .block {
        width: 50px;
        height: 50px;
        border: 1px solid lime;
        display: inline-block;
        margin: .2rem;
        background-color: white;
    }
    

提交回复
热议问题