gpt4 book ai didi

asp.net - 即使列更改也保持宽度。 (HTML)

转载 作者:行者123 更新时间:2023-11-28 13:49:33 27 4
gpt4 key购买 nike

我在我网站的左侧边栏上有一个登录名。当用户登录时,边栏宽度不会与用户未登录时保持相同。

有没有办法保持宽度不变?

<!-- Start Sidebar -->
<td id="sidebar" valign="top" height="400px" style="width: 200px">
<!-- Login Form -->
<table id="TABLE2">
<tr>
<td valign="top">
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<br />
<br />
You are currently logged in.
</LoggedInTemplate>
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server" BorderPadding="0" BorderStyle="None" BorderWidth="0px"
Font-Names="Verdana" Font-Size="0.8em" CreateUserText="Sign Up Now!" CreateUserUrl="http://www.tiltonindustries.com/Tilton/Login/CreateAccount.aspx"
Height="1px" PasswordRecoveryText="Forgot your password?" PasswordRecoveryUrl="http://www.tiltonindustries.com/Tilton/Login/ForgotPassword.aspx"
TextLayout="TextOnTop" Width="200px" DestinationPageUrl="http://www.tiltonindustries.com/Tilton/default.aspx">
<TitleTextStyle Font-Bold="True" Font-Size="0.9em"/>
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" />
<LayoutTemplate>
<table border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse;
height: 159px;">
<tr>
<td style="height: 176px; width: 135px;">
<table border="0" cellpadding="0" style="width: 219px; height: 1px" id="TABLE1">
<tr>
<td align="center" style="font-weight: bold; font-size: 0.9em; color: white; height: 18px;
background-color: #990000; text-align: center" colspan="2">
Log In</td>
</tr>
<tr>
<td style="width: 94px; height: 10px;">
</td>
<td style="height: 10px; width: 78px;">
</td>
</tr>
<tr>
<td style="width: 94px; height: 20px; text-align: right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
&nbsp;
</td>
<td style="height: 20px; text-align: left; width: 78px;">
<asp:TextBox ID="UserName" runat="server" Font-Size="0.9em" EnableViewState="False"
Width="100px" MaxLength="20"></asp:TextBox><asp:RequiredFieldValidator ID="UserNameRequired"
runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="ctl01$Login1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 94px; text-align: right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
&nbsp;
</td>
<td style="text-align: left; width: 78px;">
<asp:TextBox ID="Password" runat="server" Font-Size="0.9em" TextMode="Password" Width="100px"></asp:TextBox><asp:RequiredFieldValidator
ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="ctl01$Login1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="height: 20px; width: 94px;">
&nbsp;</td>
<td style="height: 20px; text-align: left; width: 78px;">
<asp:CheckBox ID="chkRememberMe" runat="server" Text="Remember Me" Width="104px" /></td>
</tr>
<tr>
<td align="center" style="color: red; width: 94px; height: 20px;">
</td>
<td align="center" style="color: red; text-align: left; width: 78px; height: 20px;">
<asp:Button ID="LoginButton" runat="server" BorderStyle="Solid" BorderWidth="1px"
CommandName="Login" Font-Names="Verdana" Font-Size="1.0 em" Text="Log In" ValidationGroup="ctl01$Login1"
Width="59px" BackColor="Gray" BorderColor="Black" Height="20px" /></td>
</tr>
<tr>
<td align="center" style="width: 250px; color: red; height: 35px; text-align: center;"
colspan="2">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal></td>
</tr>
<tr>
<td style="height: 26px; width: 94px;">
<asp:HyperLink ID="CreateUserLink" runat="server" NavigateUrl="http://www.tiltonindustries.com/Tilton/Login/CreateAccount.aspx">Sign Up Now!</asp:HyperLink>&nbsp;
</td>
<td style="width: 78px; height: 26px">
<asp:HyperLink ID="PasswordRecoveryLink" runat="server" NavigateUrl="http://www.tiltonindustries.com/Tilton/Login/ForgotPassword.aspx">Forgot your password?</asp:HyperLink></td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</AnonymousTemplate>
</asp:LoginView>
<!-- End Login Form -->
<!-- Quick Links -->
<br />
<br />
<p style="font-size: 14px; font-weight: bold; color: White">
Quick Links:<br />
</p>
<br />
<p id="quicklinks">
<a href="default.aspx">Home</a><br />
<a href="services.aspx">Services</a><br />
<a href="matching.aspx">Color Matching</a><br />
<a href="packaging.aspx">Custom Packaging</a><br />
<a href="decorals.aspx">Decorals</a><br />
<a href="delivery.aspx">Delivery</a><br />
<a href="items.aspx">Items</a><br />
<a href="msds.aspx">MSDS</a><br />
<a href="plant.aspx">Plant Capabilities</a><br />
<a href="standard.aspx">Standard Colors</a><br />
<a href="special.aspx">Special Effects</a><br />
<a href="coatings.aspx">Spray Coatings</a><br />
<a href="warranty.aspx">Warranty</a><br />
<a href="http://www.tiltonindustries.com/Tilton/Login/Login.aspx">My Account</a><br />
<a href="gallery.aspx">Gallery</a><br />
<a href="about.aspx">About</a><br />
<a href="faq.aspx">F.A.Q</a><br />
<a href="links.aspx">Links</a><br />
<a href="careers.aspx">Careers</a><br />
<a href="contact.aspx">Contact</a><br />
<br />
</p>
</td>
</tr>
</table>
</td>
<!-- End Sidebar -->

最佳答案

如果标记相同,您总是可以在 CSS 中为其添加固定宽度:

<div id="sidebar">
...
</div>

#sidebar { width: 200px; }

当然,这假设边栏本身的标记在登录和未登录时都是相同的。

...假设您使用非表格布局。您仍然可以在侧边栏单元格上设置固定宽度,但表格通常不应用于布局目的。

编辑:啊,还有代码。我建议您阅读 CSS(谷歌“CSS 教程”等)并从您的代码中删除所有样式属性。它今天的样子使它真的非常难读,而且不容易更改。

关于asp.net - 即使列更改也保持宽度。 (HTML),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3038907/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com