<html>
<head>
<style type="text/css">
div
{
border:1px solid #333;
width:500px;
}p
{
border:1px solid #333;
width:400px;
margin-left:auto;
margin-right:auto;
}</style>
</head>
<body><div>
<p>
我是p标签,要水平居中,但在ie中无效,怎么办?。
</p>
</div></body>
</html>

解决方案 »

  1.   


    p
    {
    border:1px solid #333;
    width:400px;
    text-align:center;
    }试试
      

  2.   

    额,错了。p
    {
    border:1px solid #333;
    width:400px;
    text-align:center;
    margin:0px auto;
    }
      

  3.   

    div
    {
    border:1px solid #333;
    width:500px;
    text-align:center;
    }
      

  4.   


    代码改为如下即可:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    div
    {
    border:1px solid #333;
    width:500px;
    }p
    {
    border:1px solid #333;
    width:400px;
    margin-left:auto;
    margin-right:auto;
    }</style>
    </head>
    <body><div>
    <p style="text-align:center;">
    我是p标签,要水平居中,但在ie中无效,怎么办?。
    </p>
    </div></body>
    </html>
      

  5.   

    <style type="text/css">
    div
    {
    border:1px solid #333;
    width:500px;
    }p
    {
    border:1px solid #333;
    width:400px;
    margin-left:auto;
    margin-right:auto;
    }
    东莞SEO www.tseoo.com