如何通过其内容确定TD标签的宽度. [英] How to determine width of TD tag by its content.

查看:598
本文介绍了如何通过其内容确定TD标签的宽度.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的是TD标签的宽度应由其内容自动确定.
我将以下内容用于测试目的.

What I want is width of TD tag should be automatically determine by its content.
I use following things for testing purpose.

<table cellpadding="0" cellspacing="0" style="width: 100%;">
        <tr>
            <td>
                Employee number*
            </td>
            <td>
                <asp:TextBox runat="server" ID="txtEmployeeNumber">
            </td>
            <td>
                Employee name*
            </td>
            <td>
                <asp:TextBox runat="server" ID="txtEmployeeName">
            </td>
        </tr>
    </table>



但是我得到的是全部四个专栏完全分为四个部分.
我的要求是,最后一列可能包含剩余空间.
但是前三列的大小必须等于其内容.


在此先感谢..



but what i get is all four column is divided in exactly four part.
My requirement is that, last column may contain remaining space.
But first three columns must have size equivalent to its content.


Thanks in advance..

推荐答案

好吧,您不喜欢最后一个答案,请尝试以下答案:

Okay, you didn''t like the last answer, try this one:

<table width="100%">
    <tr>
        <td width="111">Employee number*</td>
        <td width="120"><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
        <td width="93">Employee name</td>
        <td><asp:TextBox ID="TextBox2" Width="100%" runat="server"></asp:TextBox></td>
    </tr>
</table>



上面的代码将使前三列尽可能地窄,而第四列将占用余下的所有空间.您所要做的就是浏览一个简单的asp.net网页,其中仅包含一个简单的表格即可解决该问题.

简而言之,表格会自动使列的宽度相同.我知道要解决的唯一方法是在每列上都设置固定宽度或百分比.您甚至可能还需要设置对齐方式.了解如何使用Google.



The code above will make the first three columns as narrow as they can be, and the fourth with take up all the rest of the room. All you had to do was play around with a simple asp.net web page that contained nothing more than a simple table to figure it out.

Simply stated, a table is automatically going to make the columns all the same width. The only way I know of to address that is to set either fixed widths or percentages, of both on every column. You may even need to set alignment as well. Learn how to google.


这是不可能的....
您至少需要提及前3列的宽度,以便最后一列将自动采用该宽度.
Its not possible....
you need to at least mention the first 3 columns width, so that the last column will take the width automatically.


这篇关于如何通过其内容确定TD标签的宽度.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆