sar*_*ake 5 css vertical-alignment
这是我的代码
<div style="margin:0;padding:0;vertical-align:text-top; border:1px solid red;float:right;">
<span>Key:</span>
<asp:TextBox ID="tbKey" MaxLength="16" runat="server" ></asp:TextBox>
<asp:ImageButton ID="btnRefresh" runat="server" imageUrl="_img/btn_submit.gif" Height="22" Width="52" />
</div>
Run Code Online (Sandbox Code Playgroud)
我希望所有三个元素都排在最前面.这可行吗?
编辑:源代码(渲染)是
<div style="margin:0;padding:0;vertical-align:text-top; border:1px solid red;float:right;">
<span>Key:</span>
<input name="tbKey" type="text" maxlength="16" id="tbKey" />
<input type="image" name="btnRefresh" id="btnRefresh" src="_img/btn_submit.gif" style="height:22px;width:52px;border-width:0px;border-width:1px;" />
</div>
Run Code Online (Sandbox Code Playgroud)
har*_*rpo 13
我经常使用
display: inline-block;
Run Code Online (Sandbox Code Playgroud)
在这种情况下.这应该会使布局受到尊重
vertical-align: top;
Run Code Online (Sandbox Code Playgroud)
规则.
这类似于@Jason Ellis的table-cell解决方案,但更具语义性,因为这不是一个表.
尝试vertical-align: text-top为您的按钮提供该属性。在CSS中:
#btnRefresh
{
vertical-align: text-top;
}
Run Code Online (Sandbox Code Playgroud)
或者添加VerticalAlign="Top"到您的 ImageButton 控件(不确定最后一个如何转换为 CSS)。