动态扩展TD的宽度
有没有办法根据下一个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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要尝试的一件事是保留需要根据其他 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.
使用 jQuery,您可以将 id 应用于两列中的顶部 td,然后执行以下操作:
如果 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:
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.