Front-end design - layout - navigation bar - div centering

1. A navigation bar:

<header style="font-family: 宋体, Arial, Helvetica, sans-serif; font-size: xx-large; line-height: 50px; text-align: center; padding-left: 30px">
        <nav>
            <a href="https://blog.csdn.net/weixin_43917370">学习网站</a> |
            <a href="http://acm.heyuantao.cn/faqs.php">常见问答</a> |
            <a href="/js/">问题</a> |
            <a href="/jquery/">状态</a> |
            <a href="/js/">排名</a> 
        </nav>
    </header>

The effect is as follows:

2. div layout

<div style="border-style: ridge;  padding-top:20px;padding-left: 200px; margin: auto; width: 50%;">
    <span class="auto-style2">   登录界面</span><br class="auto-style2" />
        <br class="auto-style2" />
        <span class="auto-style2">学号:</span><asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style2"></asp:TextBox>
        <br class="auto-style2" />
        <br class="auto-style2" />
        <span class="auto-style2">姓名:</span><asp:TextBox ID="TextBox2" runat="server" CssClass="auto-style2"></asp:TextBox>
        <br class="auto-style2" />
        <br class="auto-style2" />
        <asp:Button ID="Button1" runat="server" Height="45px" OnClick="Button1_Click" Text="登录" Width="79px" CssClass="auto-style2" />
    
        <span class="auto-style2">    <asp:Button ID="Button2" runat="server" Height="41px" OnClick="Button2_Click" Text="注册" Width="86px" CssClass="auto-style2" />
        <asp:Label ID="Label1" runat="server" Text="Label" CssClass="auto-style2"></asp:Label>
    
        </span><br />
    
    </div>

1. Set the width of the style of the div as a percentage, such as 50%, which accounts for 50% of its parent window. This can change with the screen size;

2. Set the margin:auto of the style of the div to center the div.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324112917&siteId=291194637