Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在HTML表格中单独编辑TDs的宽度_Html_Css_Width_Html Table - Fatal编程技术网

在HTML表格中单独编辑TDs的宽度

在HTML表格中单独编辑TDs的宽度,html,css,width,html-table,Html,Css,Width,Html Table,如何分别更改不同TDs的宽度?这意味着,如果我更改TD的宽度,列的宽度不会受到影响,而只会影响行的宽度。例如: 我怎样才能做到这一点?我已经尝试过分别改变每个TD的宽度,但是,当我这样做时,它会改变整个列本身的宽度 以下是我表格的代码: <table> <tr> <td>Name:</td> <td> <input type="text" name="user" pl

如何分别更改不同TDs的宽度?这意味着,如果我更改TD的宽度,列的宽度不会受到影响,而只会影响行的宽度。例如:

我怎样才能做到这一点?我已经尝试过分别改变每个TD的宽度,但是,当我这样做时,它会改变整个列本身的宽度

以下是我表格的代码:

<table>
    <tr>
        <td>Name:</td>
        <td>
            <input type="text" name="user" placeholder="Your Name" maxlength="20">
        </td>
    </tr>
    <tr>
        <td>Email Address:</td>
        <td>
            <input type="text" name="email" placeholder="Your Email Address">
        </td>
    </tr>
    <tr><td>Message:</td></tr>
    <tr>
        <td colspan="2">
            <textarea rows="10" cols="50" name="message" maxlength="500"></textarea>
        </td>
    </tr>
    <tr><td colspan="2"><center><img src="test.php" alt="" /></center></td></tr>
    <tr><td style="text-align:right">Enter the Code:</td><td><input id="security_code" name="security_code" type="text" placeholder="Enter the Code Above"/></td></tr>
</table>

你不能用桌子做你想做的事。表格的整体理念是TD保持相互一致

如果要执行此操作,请停止使用表,只需将标签与输入元素一起使用,如下所示:

<label>Name: <input type="text" name="user" placeholder="Your Name" maxlength="20"></label>
<label>Email Address: <input type="text" name="email" placeholder="Your Email Address"></label>
<label> Message: <textarea rows="10" cols="50" name="message" maxlength="500"></textarea></label>

你试过把它嵌入CSS吗

.type_two{ width:50px; }
可能需要修改代码以及px和%使用率

<td class="type_two">some type of text</td>