Align a div to center

后端 未结 14 2147
别跟我提以往
别跟我提以往 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:34

    this works nicely

    width:40%; // the width of the content div
    right:0;
    margin-right:30%; // 1/2 the remaining space
    

    This resizes nicely with adaptive layouts also..

    CSS example would be:

    .centered-div {
       position:fixed;
       background-color:#fff;
       text-align:center;
       width:40%;
       right:0;
       margin-right:30%;
    }
    

提交回复
热议问题