tags:

views:

134

answers:

4

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="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

+1  A: 

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;
}
Catfish
I have tried td borders but it looks like this in iehttp://jsfiddle.net/uRv5a/42/
phpExe
A: 

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.

Jamie Dixon
but not in firefox :(
phpExe
Put it in your seperate IE stylesheet :-)
Jamie Dixon
edl's answer is a better answer infact.
Jamie Dixon
If it solves your problem in IE (which version(s) ?) but creates ont in Fx, Saf, Chr and Op then use a conditional comment to target only IE6 or IE7 and lower or IE8 and lower. Beware that if it's OK in IE8 you mustn't target it (and to be future-proof, trust IE9 developers that it won't need this negative margin either /me crossing fingers)
Felipe Alsacreations
This cannot solve in ie7 : http://jsfiddle.net/uRv5a/56/I have tried ANYTHING but no result
phpExe
+1  A: 

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. :)

edl
with display:block there is gap yet :(
phpExe
+1  A: 

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;
}
Mark Schultheiss
@Mark Schultheiss, Thanks alot, This is very cool solution and my problem is solve by this. (but extra 100 class)
phpExe
Yes, extra class, but you might avoid that with some inovative javascript instead (or jQuery selector/manipulation)
Mark Schultheiss
@Mark Schultheiss, You are right, thansk alot for share your experinces.
phpExe