HTML/CSS:td nr 中的 Div。 2 在 td 1 中的 div 下垂直对齐
我遇到了一个问题:S 我正在尝试将一个 div 和一个表格添加到两个 td 中,并通过 css 垂直对齐它们。看起来像这样:
<table>
<tr>
<td style='vertical-align: text-top;'>
<table>
<tr>
<td>Some Randomness on some lines<br><br><br>until here.</td>
</tr>
</table>
</td>
<td style='vertical-align: text-top;'>
<div style='width: 300px; height: 300px; border: 1px solid red;'>
Some Random text here also on a few lines...<br><br><br>until here.
</div>
</td>
</tr>
</table>
现在,div 正好出现在左表最后一行的级别上。为什么会这样呢? .....我之前在图像方面遇到过这个问题,但我只是通过调整图像大小解决了它......
感谢您的帮助!
弗洛
I got a problem :S I'm trying to add a div and a table into two tds and align them vertically by css. This looks like this:
<table>
<tr>
<td style='vertical-align: text-top;'>
<table>
<tr>
<td>Some Randomness on some lines<br><br><br>until here.</td>
</tr>
</table>
</td>
<td style='vertical-align: text-top;'>
<div style='width: 300px; height: 300px; border: 1px solid red;'>
Some Random text here also on a few lines...<br><br><br>until here.
</div>
</td>
</tr>
</table>
Now, the div appears just on the level of the last row of the left table. Why is this like this? ..... I got this problem earlier with images, but i just solved it by resizing the image...
Thanks for help!
Flo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用“
vertical-align:top
”try to use "
vertical-align:top
"从问题中不确定您要做什么,但如果您希望它们垂直对齐,您可以更改 HTML 使其只是一张表:
示例: http://jsfiddle.net/jasongennaro/Q5YGm/
Not sure from the question what you are trying to do, but if you want them aligned vertically, you can change your HTML to make this just one table:
Example: http://jsfiddle.net/jasongennaro/Q5YGm/
我使用 HTML 设置 TD 的宽度和高度,使用 TD 上的 valign 属性,最后使用 style 属性使用 CSS 设置 TD 边框的样式。
I'd set the width and height of the TD's using HTML, use the valign property on the TD's, and finally use the style property to style your TD's border using CSS.