新建了一个网站,就自己新建了一个index.master,然后派生出一个default.aspx。index.master页面部分代码:head runat="server">
    <title>Index MasterPage</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body style="background-color: #000000; background-repeat: repeat-x; text-align: center; width: 900px;">
    <form id="form1" runat="server">
    <div align="center">
        <table class="style1" align="center">
            <tr>
                <td>
                    <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></td>
                    </asp:ContentPlaceHolder>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
    </div>
    </form>
</body>default.aspx中部分代码,其中logo_top.jpg就是一个900px宽的图片<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Image ID="Image1" runat="server" ImageUrl="~/images/logo_top.jpg" />
</asp:Content>以上网页结构,运行default.aspx的时候发现图片是居左的啊,郁闷!!我明明设置了居中的啊!!请朋友帮忙!!

解决方案 »

  1.   

    不好意思,index.master漏写了一个</td>,但是写上以后还是无法居中
      

  2.   

    开发使用的是vs2008,直接在向导里面新建网站的,浏览使用的IE8和Maxthon2,都无法居中显示啊!
      

  3.   

    <body style="background-color: #000000; background-repeat: repeat-x; text-align: center; width: 900px; margin:0 auto">
      

  4.   

     <div align="center">
            <table class="style1" align="center">
                <tr>
                    <td>
                        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></td>
                        </asp:ContentPlaceHolder>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        </div>--------------------------------居中只需要设置上面的 <div align="center">就行了
    <div style="width:980px; margin: 0 auto;">
      

  5.   

    <div style="margin: 0 auto;">