如何在使用 aspx 时将我的日期输入字段居中?

huangapple go评论66阅读模式
英文:

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>&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" />&nbsp;
                        </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" />&nbsp;
                    </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?

如何在使用 aspx 时将我的日期输入字段居中?

Here is the code sample I'm working with:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

  &lt;td valign=&quot;top&quot; class=&quot;style1&quot;&gt;
&lt;div id=&quot;patientFilterDiv&quot; style=&quot;width: 280px; height: 390px;&quot; class=&quot;nonScrollingDiv1&quot;&gt;
&lt;span id=&quot;spnDateFields&quot;&gt;
&lt;table align=&quot;center&quot; class=&#39;listStyle1&#39;&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;span id=&quot;spnBeginDate&quot;&gt;Begin Date&lt;/span&gt;&amp;nbsp;
&lt;/td&gt;
&lt;td&gt;
&lt;span id=&quot;spntxtBeginDate&quot;&gt;
&lt;input id=&quot;beginDate&quot; type=&quot;text&quot; runat=&quot;server&quot; name=&quot;beginDate&quot; style=&quot;width: 72px;&quot;&gt;&lt;/span&gt;&amp;nbsp;
&lt;/td&gt;
&lt;td&gt;
&lt;span id=&quot;spnBeginDateImage&quot;&gt;
&lt;img id=&quot;selectBeginDate&quot; onclick=&quot;SelectBeginDate();&quot; src=&quot;../../Images/calendar.gif&quot;
style=&quot;cursor: hand&quot; /&gt;&lt;/span&gt;&amp;nbsp;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;span id=&quot;spnEndDate&quot;&gt;End Date&lt;/span&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;input id=&quot;endDate&quot; type=&quot;text&quot; runat=&quot;server&quot; name=&quot;endDate&quot; style=&quot;width: 72px;&quot;&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img id=&quot;selectEndDate&quot; onclick=&quot;SelectEndDate();&quot; src=&quot;../../Images/calendar.gif&quot;
style=&quot;cursor: hand&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/span&gt;
&lt;span id=&quot;spnMonthliesOnly&quot;&gt;
&lt;table align=&quot;center&quot; class=&#39;listStyle1&#39;&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input id=&quot;majorsOnly&quot; type=&quot;checkbox&quot; /&gt;Monthlies Only&lt;/br&gt; &lt;span style=&quot;display: none&quot;&gt;
&lt;input id=&quot;chkEndOfMonth&quot; type=&quot;checkbox&quot; /&gt;Last Test Of The Month&lt;/span&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;/td&gt;

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

如何在使用 aspx 时将我的日期输入字段居中?

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:

    &lt;asp:TextBox ID=&quot;txtDate&quot; runat=&quot;server&quot;
TextMode=&quot;Date&quot; Width=&quot;120px&quot;&gt;
&lt;/asp:TextBox&gt;

and you thus get this:

如何在使用 aspx 时将我的日期输入字段居中?

Regardless, you can center the text in that text box by adding text-align with this:

        &lt;input id=&quot;endDate&quot; type=&quot;text&quot; 
runat=&quot;server&quot; 
name=&quot;endDate&quot; 
style=&quot;width:92px;text-align:center;&quot;&gt;

huangapple
  • 本文由 发表于 2023年3月10日 00:41:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/75687575.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定