在我的网站上,我有一个表格列表,这些表格在特定日期为运动员设置了一系列训练。
我想添加输入他们如何做的功能。我希望它以某种方式工作,以便当您将鼠标悬停或单击培训时,一个 div 会向下滚动以显示所取得的成就。
我目前在 while 循环中有以下代码:
$sessTable .= '<table border = "1px solid black" style="width:100%; border-collapse: collapse">
<tr>
<td colspan="2" style="background-color:#E8E8E8 ">' .$newDate. '' .$attendBtn. '</td>
</tr>
<tr>
<td><div style=" float:left" >' .$session. '</div>' .$editBtns. '</td>
</tr>
</table>
<div class="diary">
testing the div theory.<br/>
to see if it<br/>
will slide up and down
</div>';
CSS
.diary {
width: 100%;
height: 10px;
background: #FFF;
-webkit-transition: width 2s; /* For Safari 3.1 to 6.0 */
transition: height 2s;
font-size:0px;
}
.diary:hover {
height: 300px;
font-size:12px;
background:#CCC
}
当我在单个 div 上尝试时它似乎工作正常但是当我将它放在 while 循环中时悬停工作正常但似乎忽略了初始 .diary
状态并且也只是直接跳转到没有过渡的悬停状态。
我的问题是这对多个 div 是否可行,或者是否有更好的方法来实现我的需要。
最佳答案
因为你只为height
设置了transition
.diary {
width: 100%;
height: 10px;
background: #FFF;
-webkit-transition: height 2s,background 2s;;
/* For Safari 3.1 to 6.0 */
transition: height 2s,background 2s;;
font-size: 0px;overflow:hidden
}
.diary:hover {
height: 300px;
font-size: 12px;
background: #CCC
}
<div class="diary">
testing the div theory.
<br/>to see if it
<br/>will slide up and down
</div>
关于php - css 转换在循环时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38305571/