即使列发生变化也保持宽度。 (HTML)

发布于 2024-09-05 18:58:30 字数 12490 浏览 2 评论 0原文

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

有没有办法保持宽度相同?

<!-- 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 -->

I have a login on the left sidebar of my website. When a user is logged in, the sidebar width doesn't remain the same as it was when the user wasn't logged in.

Is there a way to keep the width the same?

<!-- 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>
                                                                     
                                                                </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>
                                                                     
                                                                </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;">
                                                                     </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> 
                                                                </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 -->

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请叫√我孤独 2024-09-12 18:58:40

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

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

#sidebar { width: 200px; }

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

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

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

If the markup is the same, you could always just add a fixed width to it in CSS:

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

#sidebar { width: 200px; }

This, of course, assumes the markup for the sidebar itself is the same both when logged in and when not logged in.

...assuming you use a non-table layout. You can still set a fixed width on the sidebar-cell, but tables should generally not be used for layout purposes.

Edit: Ah, and there is the code. I advice you to read up on CSS (google "CSS tutorial" and the like) and remove all the style-attributes from your code. The way it looks today makes it really, really unreadable and not very easily changeable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文