我有一个 html 表,其中 ( td
) 单元格包含文本输入 (<input type="text"/>
)。一切都很好(用户可以输入 OK),除非我 .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;
位解决了这个问题!或者,删除 tbody
、tr
和 td
也有效。非常感谢人们的帮助。
关于javascript - 当使用 javascript/jquery 添加值时,html 文本输入表无法正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12047726/