Qualcuno sa perché gli elementi di input con una larghezza del 100% vanno oltre il bordo delle celle della tabella.Casella di testo di input HTML con una larghezza del 100% che supera le celle della tabella
Nell'esempio seguente, la casella di input va oltre il bordo delle celle della tabella, il risultato è orribile. Questo è stato testato e succede allo stesso modo su: Firefox, IE7 e Safari.
Ha senso per te? Mi manca qualcosa, sai una possibile soluzione?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <!-- don't use closing slash in meta tag, it breaks HTML4.01 transitional -->
<title>Test input text in table</title>
<style type="text/css">
table {border-top: 1px solid #ff0000; border-left: 1px solid #ff0000;}
table td {border-right: 1px solid #00ff00; border-bottom: 1px solid #00ff00;}
input[type="text"] {width: 100%;} /* removing this would make input not to go over cells border, but they would be too short, I want them to fit cells size */
</style>
</head><body>
<table cellpadding="0" cellspacing="0">
<tr>
<td><p>column one hello babe babe babe</p></td>
<td><p>column two hello babe more</p></td>
<td><p>column three hello babe more and more</p></td>
</tr>
<tr>
<td><input type="text" value="test"></td>
<td><input type="text" value="test"></td>
<td><input type="text" value="test"></td>
</tr>
</table>
</body></html>
I suggerirebbe che, se si sta solo usando una tabella per presentare gli input, si potrebbe passare ad usare un 'form' con' label' s e 'input' s all'interno di' ul' o 'ol'. che è, almeno leggermente più semantico. Certamente, però, dovresti usare un 'form', anche se ti limiti a' table'. –