Reputation: 2003
I was testing this on fiddle:
<table>
<tr>
<td class="changeme">something</td>
<td>something</td>
<td>something</td>
<td>something</td>
<td>something</td>
</tr>
<tr>
<td class="changeme">something</td>
<td>something</td>
<td>something</td>
<td>something</td>
<td>something</td>
</tr>
<tr>
<td class="changeme">something</td>
<td>something</td>
<td>something</td>
<td>something</td>
<td>something</td>
</tr>
<tr>
<td class="changeme">something</td>
<td>something</td>
<td>something</td>
<td>something</td>
<td>something</td>
</tr>
</table>
and this css:
.changeme:hover {
border:outset;
cursor:pointer;
}
I just wanted to create a little popping out like effect on the td tag but it has this weird wavy effect when you run the mouse up and down the column, how could I remove that?
Upvotes: 2
Views: 2581
Reputation: 157324
You can also use outline
instead of border
property, which would suit better in this particular scenario
.changeme:hover {
outline:2px solid #f00;
padding:2px;
cursor:pointer;
}
Why using border
causes that offset? If you are aware of CSS Box Model, the border
is counted outside the element instead of inside, and thus it shakes your element on hover.
There are various ways to solve this issue, one can also use transparent
border color to reserve the border space like
.changeme{
padding:2px;
border: 2px solid transparent;
}
.changeme:hover {
border:2px solid #f00;
padding:2px;
cursor:pointer;
}
Upvotes: 6
Reputation: 71150
Try doing:
.changeme{
padding:2px;
}
.changeme:hover {
border:2px outset;
padding:0;
cursor:pointer;
}
The 'pop' is happening because the width of the border is being added on hover, offsetting the other table cells. To counteract this, set padding on a cell the same as the width of the border you wish to apply, then remove on hover. The border will then fill this space seamlessly, keeping the table structure in place.
Upvotes: 3