html - V 对齐顶部在 TD 内不起作用

标签 html asp.net css web-applications user-interface

我有一个 asp.net gridview,其中呈现的 HTML 如下(仅第一列)

我想将所有三个控件对齐到 TD 内的顶部。

我尝试将 vertical-align: top; 添加到 TD,但没有按预期工作。它在顶部显示了一些空间。我还尝试在 TD 中添加 DIV,在 DIV 中放置控件并设置 DIV vertical-align:top; 的 CSS 属性;显示:表格行;

也没用。 这个问题在 chrome 和 IE 中,不是 FF

<td>      
        <input id="ctl00_PH_GridViewOrderDetails_ctl02_cbView" type="checkbox" name="ctl00$PH$GridViewOrderDetails$ctl02$cbView"
            onclick="chkSelect(this.checked, this.id, 'chkView', 'cbView');">
        <span id="ctl00_PH_GridViewOrderDetails_ctl02_LineNo" style="font-size: 11px;">100 (10)</span>
        <img title="k@abc.com" src="Images/email.gif" >

</td>

最佳答案

你需要添加 vertical-align: top to all of items on your td not at td element:

td.yourIDorClass input, 
td.yourIDorClass img, 
td.yourIDorClass span {

    vertical-align: top;
}

或者你可以在后面的代码中为所有控件添加属性

youcontrolId.Attributes.Add("style", "vertical-align: top");

关于html - V 对齐顶部在 TD 内不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18141097/

相关文章:

html - 为什么我的 div 没有正确堆叠?

javascript - 使用 Javascript 呈现 HTML 的策略

html - 为什么 flex 元素不缩小过去的内容大小?

html - 推特 Bootstrap 3 : Small Offset/Margin

html - 最小宽度与最大宽度媒体查询 CSS

c# - 使用 CSS 设置 GridView 格式

asp.net - GridView 更新后覆盖 editindex

asp.net - IIS 中的静态压缩不适用于 htm、js 文件

asp.net - 我应该在 Web 应用程序中嵌入 CSS/JavaScript 文件吗?

html - 我将如何防止此表单内容离开框架?