gpt4 book ai didi

html - 需要将表格垂直放置在高度为 500 像素的 div 中间

转载 作者:行者123 更新时间:2023-11-28 01:40:24 27 4
gpt4 key购买 nike

我想将我的表格定位为 vertical-align as middle 和 text-align as center of the div which has has has height of 500px, 但我的表格只是居中对齐并且它没有垂直对齐 div 的中间。

/* CSS - I am refering the below css from a external file.

    .login {
position: relative;
margin: 0 auto;
min-height: 500px;
display: block;
border: .5px solid;
border-color: lightgray;
}

.logintable {
position: relative;
border-style: solid;
border-color: lightgray;
border-width: 1.5px;
padding: 0px;
border-spacing: 0px;
text-align: center;
vertical-align: bottom;
left: 30%;
height: 50%;
bottom: 50%;
}*/
</style> </head> <body>

<div id="login" class="login">

<table class="logintable">
<tbody>
<tr>
<td colspan="2">Log In</td>
</tr>
<tr>
<td>
<label id="lblUserName">User Name</label>
</td>
<td>
<asp:textbox id="txtUserName" runat="server"></asp:textbox>
</td>
</tr>
<tr>
<td>
<label id="lblPassword">Password</label>
</td>
<td>
<asp:textbox id="txtPassword" runat="server" textmode="Password"></asp:textbox>
</td>
</tr>

<tr>
<td colspan="2">
<asp:button id="LoginButton" runat="server" text="Login" onclick="LoginButton_Click" />
</td>
</tr>
</tbody>
</table>
</div> </body> </html>

最佳答案

将此样式添加到表中

position: absolute;
vertical-align: middle

http://jsfiddle.net/vqfpwfeL/1/

关于html - 需要将表格垂直放置在高度为 500 像素的 div 中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26495874/

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