0

我正在尝试使用 loginstatus 控件将在选择登录后显示的登录控件居中。

<div id="linkContent">
    <asp:LoginStatus ID="LoginStatus2" runat="server" 
        LogoutAction="RedirectToLoginPage" />
</div>

我尝试了几种在谷歌上找到的不同方法,但都没有奏效。我正在使用 IE 9。

我试过了:

#linkContent
{
text-align: center;
}

我努力了:

<div id="linkContent">
    <asp:LoginStatus ID="LoginStatus2" runat="server" 
        LogoutAction="RedirectToLoginPage" style="text-align: center;" />
</div>

我试过了:

#linkContent
{
margin-left:auto;
margin-right:auto;
}

我还将登录指向我自己的 Login.aspx,但它也不起作用:

在网络配置中:

<authentication mode="Forms" >
    <forms loginUrl="Login.aspx" />
</authentication>

这些都没有奏效。登录控件保持左对齐。loginStatus 控件在母版页中使用。

任何帮助,将不胜感激。

谢谢。

4

2 回答 2

1

使用内联样式(将其移动到您的 CSS 文件中!):

<div style="width: 500px; margin: 0 auto;">
    <asp:LoginStatus ID="LoginStatus2" runat="server" LogoutAction="RedirectToLoginPage" />
</div>

将 500px 更改为控件的宽度。

于 2011-12-15T16:58:34.327 回答
0

您需要将margin-left: autoand放在控件生成margin-right: auto;的标记上,而不是包含元素。LoginStatus

假设您的 中有ClientIDMode="Static"web.config并且登录静态控件生成的 HTML 将具有idof LoginStatus2,这将起到作用:

#LoginStatus2
{
    margin-left:auto;
    margin-right:auto;
}
于 2011-12-15T17:01:35.087 回答