0

我有一张桌子,我想做的是在每个将溢出的单元格中放置一个 div: hidden 以便当有人将鼠标悬停在图像上时,div 会下降。问题是这样做会随着 div 大小的增加而增加。该怎么办?CSS:

.table{
position:fixed;
top:50px;
left:200px;
table-layout:fixed;
}
.table td p{
position:relative;
margin:0;
}
.table td{
height:250px;
width:240px;
overflow:hidden;
  }
  .table td div{
position:relative;
height:50px;
top:-100px;
left:0;
text-align:center;
z-index:2;
color:#CCC;

-webkit-transition: top 0.2s;
-moz-transition: top 0.2s;
-o-transition: top 0.2s;
-ms-transition: top 0.2s;
    }
    .table td img{
position:relative;
left:20px;
top:-5px;
height:200px;
width:200px;

    }
    .table td:hover div{
-webkit-transition: top 0.2s;
-moz-transition: top 0.2s;
-o-transition: top 0.2s;
-ms-transition: top 0.2s;

top:50px;
    }

对不起,html是这样的:

   <table class="table">
    <tr>
        <td><div>description</div><img src="something.jpg" alt="Not Found"><p>Hello</p></td>
        <td><div>description</div><img src="something.jpg" alt="Not Found"><p>Hello</p></td>
    </tr>
</table>
4

1 回答 1

1

Try using position: relative in td and position absolute in div, like this:

.table td{
    position:relative;
    height:250px;
    width:240px;
    overflow:hidden;
    border:1px solid red;
}
.table td div{
    position:absolute;
    height:50px;
    top:-100px;
    left:0;
    text-align:center;
    z-index:2;
    color:#CCC;

    -webkit-transition: top 0.2s;
    -moz-transition: top 0.2s;
    -o-transition: top 0.2s;
    -ms-transition: top 0.2s;
}

Demo: http://jsfiddle.net/2hU6W/

于 2013-11-01T17:00:24.403 回答