怎样用CSS把一个DIV里的DIV居中

By admin, 12 二月, 2015

<div id="outer" style="width:100%">  
    <div id="inner">Foo foo</div>
</div>

方法一,需要制定里面DIV的宽度:
#inner {
    width: 50%;
    margin: 0 auto;
}

方法二:仅支持IE8+
#inner {
    display: table;
    margin: 0 auto;
}

标签

评论1

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
验证码
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
请输入"Drupal10"

匿名 (未验证)

8 years 5 months 之前