动态扩展TD的宽度

发布于 2024-08-17 21:38:22 字数 578 浏览 2 评论 0原文

有没有办法根据下一个TD的宽度来扩展表格中TD的宽度?

asp:Panel 将根据后面代码中的某些条件隐藏或显示。

我认为 CSS 的一些东西可以帮助我解决这个问题,但无法指出它。帮助!

这是 HTML 标记:

<tr>
 <td class="content_body" style="width: 294px">
  This is some long text needs to be dynamically wrapped...............................................................
 </td>
 <td>
  <asp:Panel ID="Panel1" runat="server">
   This is going to be hidden based on some condition in the Code behind
  </asp:Panel>
 </td>
</tr>

Is there a way for expanding the width of a TD in the table based on the width of the next TD?

The asp:Panel is going to be hidden or displayed based on some condition in the code behind.

I'm thinking it's some CSS thing that would help me fix this, but unable to put a finger on it. Help!

Here's the HTML Markup:

<tr>
 <td class="content_body" style="width: 294px">
  This is some long text needs to be dynamically wrapped...............................................................
 </td>
 <td>
  <asp:Panel ID="Panel1" runat="server">
   This is going to be hidden based on some condition in the Code behind
  </asp:Panel>
 </td>
</tr>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

烟燃烟灭 2024-08-24 21:38:22

要尝试的一件事是保留需要根据其他 TD 扩展/收缩的 TD 的宽度。如果没有宽度,TD 将默认占用任何可用空间,因此如果行中的其他 TD 都指定了宽度,则没有宽度的 TD 将占用剩余空间。如果有 2 个这样的 TD,则空间将在它们之间分配。

One thing to try would be to leave the width off of the TD that needs to expand/shrink based on the other TDs. Without a width, a TD will by default take up any available space, so if the other TDs in the row all have a width specified, the one without a width will take up the rest of the space. If there are 2 such TDs, the space will be distributed between them.

风筝有风,海豚有海 2024-08-24 21:38:22

使用 jQuery,您可以将 id 应用于两列中的顶部 td,然后执行以下操作:

$('#tda').width(($('#tdb').width() > 200) ? 10 : 100)

如果 id b 的 td 大于 200,则将 id 为 tda 的 td 的宽度设置为 10,否则会将其设置为 100。

With jQuery, you could apply an id to the top td in the two columns and then do something like:

$('#tda').width(($('#tdb').width() > 200) ? 10 : 100)

This sets the width of td with id tda to 10 if td with id b is greater than 200 else it will set it to 100.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文