新建了一个网站,就自己新建了一个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>
</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的时候发现图片是居左的啊,郁闷!!我明明设置了居中的啊!!请朋友帮忙!!
<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>
</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的时候发现图片是居左的啊,郁闷!!我明明设置了居中的啊!!请朋友帮忙!!
<table class="style1" align="center">
<tr>
<td>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></td>
</asp:ContentPlaceHolder>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>--------------------------------居中只需要设置上面的 <div align="center">就行了
<div style="width:980px; margin: 0 auto;">