HTML/CSS:td nr 中的 Div。 2 在 td 1 中的 div 下垂直对齐

发布于 2024-11-28 20:11:48 字数 769 浏览 2 评论 0原文

我遇到了一个问题: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ヅ她的身影、若隐若现 2024-12-05 20:11:48

尝试使用“vertical-align:top

<table>
  <tr>
    <td style='vertical-align: top;'>
      <table>
         <tr>
            <td>Some Randomness on some lines<br><br><br>until here.</td>
         </tr>
      </table>
    </td>
    <td style='vertical-align: 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>

try to use "vertical-align:top"

<table>
  <tr>
    <td style='vertical-align: top;'>
      <table>
         <tr>
            <td>Some Randomness on some lines<br><br><br>until here.</td>
         </tr>
      </table>
    </td>
    <td style='vertical-align: 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>
拥抱没勇气 2024-12-05 20:11:48

从问题中不确定您要做什么,但如果您希望它们垂直对齐,您可以更改 HTML 使其只是一张表:

<table>
  <tr>
    <td style='vertical-align: text-top;'>
      Some Randomness on some lines<br><br><br>until here.</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>

示例: 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:

<table>
  <tr>
    <td style='vertical-align: text-top;'>
      Some Randomness on some lines<br><br><br>until here.</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>

Example: http://jsfiddle.net/jasongennaro/Q5YGm/

似狗非友 2024-12-05 20:11:48

我使用 HTML 设置 TD 的宽度和高度,使用 TD 上的 valign 属性,最后使用 style 属性使用 CSS 设置 TD 边框的样式。

<td height="300" width="300" valign="top" style="border: 1px solid red;">
   text here
</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.

<td height="300" width="300" valign="top" style="border: 1px solid red;">
   text here
</td>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文