php - css 转换在循环时不起作用

标签 php html css

在我的网站上,我有一个表格列表,这些表格在特定日期为运动员设置了一系列训练。

我想添加输入他们如何做的功能。我希望它以某种方式工作,以便当您将鼠标悬停或单击培训时,一个 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/

相关文章:

php解压大文件

php - 为什么我的 FB 应用程序在 IE 中永远循环?

html - Rmarkdown 中 TOC 上的图像 Logo

html - vuetify v-icon 的问题

php - 在 PHP echo 中运行 PHP?

javascript - 使用外部 JS 显示隐藏信息

php - PHP Twitter API 中的“无法获取本地颁发者证书”

PHP 5.2 中的 PHP date_parse_from_format( ) 替代方案

javascript - 使用 Angular 为屏幕上的 div 设置动画

css - 从 .sass-cache 中的 scssc 文件生成 CSS