Html:如何对齐表格中的单词

时间:2014-02-25 17:59:44

标签: html css

我在另一个表的列中创建了一个表。 我想对齐这两个词 this is the image

<table width="223">
    <tr>
        <td width="215">      
            <form method="post" action="AggiornaQtaCarrelloServlet">
                <input type="text" name="quantita" pattern="[0-9]*" required value="<%=articoli.get(a).intValue()%>" size="3"/> 
                <input type="hidden" name="codice" value="<%=a.getCodice()%>"/>
                <a href="javascript:;" onclick="parentNode.submit();">Aggiorna Q.tà</a>
            </form>
        </td>
    </tr>
    <tr>
        <td>
            <form method="post" action="RimuoviArticoloDaCarrelloServlet">
                <input type="hidden" name="id_articolo" value="<%=a.getId()%>"/>
                <a href="javascript:;" onclick="parentNode.submit();">Rimuovi</a>
            </form>
        </td>
    </tr>
</table>

2 个答案:

答案 0 :(得分:2)

改变它的布局方式: DEMO

将输入和链接拆分为两个单独的td。然后在该链接之前的第二行添加空白td。然后,您需要更改第一个td的宽度。您还需要移动第一个form以围绕两个td元素,因此您必须向第一个table添加td。为了保持对齐,我对第二行的td

执行了相同的操作
<table width="223">
<tr>
    <td width="223">
        <form method="post" action="AggiornaQtaCarrelloServlet">
            <table>
                <tr>
                    <td width="50">
                        <input type="text" name="quantita" pattern="[0-9]*" required value="<%=articoli.get(a).intValue()%>" size="3" />
                        <input type="hidden" name="codice" value="<%=a.getCodice()%>" />
                    </td>
                    <td> <a href="javascript:;" onclick="parentNode.submit();">Aggiorna Q.tà</a>

                    </td>
                </tr>
            </table>
        </form>
    </td>
</tr>
<tr>
    <td width="223">
        <table>
            <tr>
                <td width="50"></td>
                <td>
                    <form method="post" action="RimuoviArticoloDaCarrelloServlet">
                        <input type="hidden" name="id_articolo" value="<%=a.getId()%>" /> <a href="javascript:;" onclick="parentNode.submit();">Rimuovi</a>

                    </form>
                </td>
            </tr>
        </table>
    </td>
</tr>
</table>

答案 1 :(得分:0)

如果你想要内联样式,你需要像

这样的东西
        <td width="215" style="text-align: center;">