开发者

input in table > td, But yet extra bottom spacing between rows! Internet Explorer

Im using meyer css reset. But I have problem with input in a table. There in extra space between rows:

<table class="table" cellpadding="0" cellspacing=开发者_如何学Go"0" border="0">
 <tr>
  <td>&nbsp;</td>
  <td>1</td>
  <td>2</td>
  <td>3</td>
  <td>4</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  <td>8</td>
  <td>9</td>
  <td>10</td>
</tr>
<tr>
  <td>1</td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text" class="black"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
 </tr>
 <tr>
  <td>2</td>
  <td><input type="text" /></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
  <td><input type="text" class="black"/></td>
  <td><input type="text"/></td>
  <td><input type="text"/></td>
</tr>
</table>

and css:

   .table {
border-collapse: collapse;
border-spacing: 0px;
    }
   .table tr {
margin-bottom:0;
overflow:hidden;
height:25px;
width: 100%;
padding:0;
   }
  .table input {
width:25px;
height:25px;
border:1px solid #000;
text-align:center;
   }
   .black {
background:#000;
    }

Why there is extra bottom spacing in internet explorer (I hate ie :(()? Thanks alot


Try making the border on the td and not on the input. Give the cells you want black a black class and the others with input the tdinput class. That way, you still get the cells with numbers without borders :)

<td>1</td>
<td class='tdinput'><input type="text"/></td>
<td class='tdinput black'><input type="text" /></td>


td.tdinput
{
    border:1px solid #000;
}
td.tdinput.black input
{
     background:#000;
}


You have to take the border off of the .inputs and actually put it on the td's.

Try this

.table {
    border-collapse: collapse;
    border-spacing: 0px;
}
.table tr {
    margin-bottom:0;
    overflow:hidden;
    height:25px;
    width: 100%;
    padding:0;
}
.table tr td {
    border:1px solid #000;
}
.table input {
    width:25px;
    height:25px;
    border:none;
    text-align:center;
}
.black {
    background:#000;
}


It's because inputs are inline elements. add display:block; to your input elements and it should take off the gap.

.table {
border-collapse: collapse;
border-spacing: 0px;
}
.table tr {
    margin-bottom:0;
    overflow:hidden;
    height:25px;
    width: 100%;
    padding:0;
}
.table tr td {
    border:1px solid #000;
}
.table input {
    width:25px;
    height:25px;
    border:none;
    text-align:center;
    display:block;
}
.black {
    background:#000;
}

Basically adding display:block; to Catfish's solution as he also makes a valid point about styling both td and input. :)


The bottom margin is being caused by the way IE is handling your input.

Adding: margin:-1px; such that:

  .table input {
width:25px;
height:25px;
border:1px solid #000;
text-align:center;
margin:-1px;
   }

Seems to fix it quite well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜