当使用javascript/jquery添加值时,html文本输入表显示不正确

html table of text inputs not displaying correctly when values added with javascript/jquery

本文关键字:文本 html 输入 不正确 显示 javascript 添加 jquery      更新时间:2023-09-26

我有一个html表,其中(td)单元格包含文本输入(<input type="text"/>)。一切都很好(用户可以在输入中键入OK),除了当I .append()输入单元格有值的行时,当在输入上方添加额外的边距时,破坏了表行的对齐(这在chrome和safari中发生,但firefox可以)。

$('.myTable').append('<tr><td><input type="text" value="product code 1"/></td>'+
     '<td><input type="text" disabled="disabled"/></td></tr>');

我在css中找不到任何内容。有人遇到/解决了这个问题吗?

疯狂的笑声!好的,我明白了!我有以下css浏览器重置代码:
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu,nav, output, ruby, section, summary,
time, mark, audio, video {
    margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;
}

删除vertical-align:baseline;位解决了问题!或者,去除tbodytrtd也起作用。非常感谢人们的帮助。