I would like to have all cells in a with "vertical-align:top" style. For technical reasons outside my control, I cannot define a new class, or change the stylesheet at all; nor can I set "style" for individual cells, or even rows. All I can do is set the "style" attribute of the <table>
element itself.
我希望所有单元格都采用“垂直对齐:顶部”样式。出于技术原因,在我的控制之外,我无法定义一个新类,或者根本改变样式表;我也不能为单个单元格或甚至行设置“样式”。我所能做的就是设置
Using <table style="vertical-align:top">
fails -- apparently, it sets the alignment of the table within its own context, not of individual cells inside it. Is there any other alternative that I'm missing?
使用
4 个解决方案
#1
3
You can use css
您可以使用css
table tr td {
vertical-align: top;
}
#2
2
No, as far as I can see there is no way to do this without some form of access to either the td
itself or a style sheet.
不,就我所见,如果没有某种形式的访问td本身或样式表,就不可能做到这一点。
Can you apply a workaround like this one? It's not pretty and invalid according to the W3C, but should nevertheless work in all browsers:
你能应用这种方法吗?根据W3C的说法,它不是漂亮的和无效的,但是应该适用于所有的浏览器:
<style type='text/css'> table.topalign td { vertical-align: top } </style>
<table class="topalign">
....
#3
-1
Set the "classic" HTML valign attribute on the table. The value will be inherited by the cells.
在表上设置“classic”HTML valign属性。值将由单元格继承。
<table valign="top">
…
See Tables, Table formatting by visual user agents, Horizontal and vertical alignment in the HTML 4 spec.
参见HTML 4规范中的表、可视化用户代理的表格式、水平和垂直对齐。
#4
-1
table tr {valign: top} In this case you don't need to use css class.
表tr {valign: top}在这种情况下,您不需要使用css类。
#1
3
You can use css
您可以使用css
table tr td {
vertical-align: top;
}
#2
2
No, as far as I can see there is no way to do this without some form of access to either the td
itself or a style sheet.
不,就我所见,如果没有某种形式的访问td本身或样式表,就不可能做到这一点。
Can you apply a workaround like this one? It's not pretty and invalid according to the W3C, but should nevertheless work in all browsers:
你能应用这种方法吗?根据W3C的说法,它不是漂亮的和无效的,但是应该适用于所有的浏览器:
<style type='text/css'> table.topalign td { vertical-align: top } </style>
<table class="topalign">
....
#3
-1
Set the "classic" HTML valign attribute on the table. The value will be inherited by the cells.
在表上设置“classic”HTML valign属性。值将由单元格继承。
<table valign="top">
…
See Tables, Table formatting by visual user agents, Horizontal and vertical alignment in the HTML 4 spec.
参见HTML 4规范中的表、可视化用户代理的表格式、水平和垂直对齐。
#4
-1
table tr {valign: top} In this case you don't need to use css class.
表tr {valign: top}在这种情况下,您不需要使用css类。