Align a div to center

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

    This worked for me.

    I included an unordered list on my page twice. One div class="menu" id="vertical" the other to be centered was div class="menu" id="horizontal". Since the list was floated left, I needed an inner div to center it. See below.

    
    
    .menu#horizontal { display: block;  float: left; margin: 0px; padding: 0 10px; position: relative; left: 50%; }
    #fix { float: right; position: relative; left: -50%; margin: 0px auto; }
    

提交回复
热议问题