英文:
How can I center my Date input field using aspx?
问题
以下是您提供的代码的翻译部分:
我正在使用08年创建的代码。我尝试将日期输入居中,但无论如何,span仍然出现在表格的顶部。
<br>
如何让这个输入字段保持在表格中央?
[![日期字段][1]][1]
[1]: https://i.stack.imgur.com/I4IVI.png
以下是我正在使用的代码示例:
<td valign="top" class="style1">
<div id="patientFilterDiv" style="width: 280px; height: 390px;" class="nonScrollingDiv1">
<span id="spnDateFields">
<table align="center" class='listStyle1'>
<tr>
<td>
<span id="spnBeginDate">开始日期</span>
</td>
<td>
<span id="spntxtBeginDate">
<input id="beginDate" type="text" runat="server" name="beginDate" style="width: 72px;"></span>
</td>
<td>
<span id="spnBeginDateImage">
<img id="selectBeginDate" onclick="SelectBeginDate();" src="../../Images/calendar.gif"
style="cursor: hand" />
</span>
</td>
</tr>
<tr>
<td>
<span id="spnEndDate">结束日期</span>
</td>
<td>
<input id="endDate" type="text" runat="server" name="endDate" style="width: 72px;">
</td>
<td>
<img id="selectEndDate" onclick="SelectEndDate();" src="../../Images/calendar.gif"
style="cursor: hand" />
</td>
</tr>
</table>
</span>
<span id="spnMonthliesOnly">
<table align="center" class='listStyle1'>
<tr>
<td>
<input id="majorsOnly" type="checkbox" />仅显示每月的日期<span style="display: none">
<input id="chkEndOfMonth" type="checkbox" />月底最后一次测试</span>
</td>
</tr>
</table>
</span>
</div>
</td>
英文:
I'm working with code that was created back in 08. I'm trying to center this date input and whenever I do so the span still ends up at the top of the table.
<br>
How can I get this input field to stay centered in this table?
Here is the code sample I'm working with:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<td valign="top" class="style1">
<div id="patientFilterDiv" style="width: 280px; height: 390px;" class="nonScrollingDiv1">
<span id="spnDateFields">
<table align="center" class='listStyle1'>
<tr>
<td>
<span id="spnBeginDate">Begin Date</span>&nbsp;
</td>
<td>
<span id="spntxtBeginDate">
<input id="beginDate" type="text" runat="server" name="beginDate" style="width: 72px;"></span>&nbsp;
</td>
<td>
<span id="spnBeginDateImage">
<img id="selectBeginDate" onclick="SelectBeginDate();" src="../../Images/calendar.gif"
style="cursor: hand" /></span>&nbsp;
</td>
</tr>
<tr>
<td>
<span id="spnEndDate">End Date</span>
</td>
<td>
<input id="endDate" type="text" runat="server" name="endDate" style="width: 72px;">
</td>
<td>
<img id="selectEndDate" onclick="SelectEndDate();" src="../../Images/calendar.gif"
style="cursor: hand" />
</td>
</tr>
</table>
</span>
<span id="spnMonthliesOnly">
<table align="center" class='listStyle1'>
<tr>
<td>
<input id="majorsOnly" type="checkbox" />Monthlies Only</br> <span style="display: none">
<input id="chkEndOfMonth" type="checkbox" />Last Test Of The Month</span>
</td>
</tr>
</table>
</span>
</div>
</td>
<!-- end snippet -->
答案1
得分: 1
First, you do realize that a rather nice built-in date picker exists by setting the text mode of the text box, say like this:
<asp:TextBox ID="txtDate" runat="server"
TextMode="Date" Width="120px">
</asp:TextBox>
and you thus get this:
Regardless, you can center the text in that text box by adding text-align with this:
<input id="endDate" type="text"
runat="server"
name="endDate"
style="width:92px;text-align:center;">
英文:
First, you do realize that a rather nice built-in date picker exists by setting the text mode of the text box, say like this:
<asp:TextBox ID="txtDate" runat="server"
TextMode="Date" Width="120px">
</asp:TextBox>
and you thus get this:
Regardless, you can center the text in that text box by adding text-align with this:
<input id="endDate" type="text"
runat="server"
name="endDate"
style="width:92px;text-align:center;">
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论