html - CSS Transition 没有相应地工作

标签 html css pug css-transitions

不确定我在这里做错了什么。悬停肯定有效,因为顶部和底部属性发生了变化,但过渡不存在。

.info{
  position:absolute;
  transition: opacity 2s; 
  top:0px;
  bottom:0px;
  right:0px;
  left:0px;
  background:rgba(0,0,0,0.8);
  color:white;
  text-align:center;
  justify-content:center;
  display:none;
  opacity:0; 
}


.content ul li:hover .info{
  top:-10px;
  bottom:10px;
  opacity:1;
  display:flex;
}

使用jade,这里是标记

div.content  
      ul 
       each item in results2
          li
            img(src='images/portfolio/#{item.image_path}')
            div.info
              span #{item.title}
                p #{item.description}

任何帮助将不胜感激:)

最佳答案

那是因为您指定了 display 属性 (display:none)。如果您删除 display:none 它应该可以正常工作。 display 属性无法转换。

尝试:

.info{
   position:absolute;
   transition: opacity 2s; 
   top:0;
   bottom:0;
   right:0;
   left:0;
   background:rgba(0,0,0,0.8);
   color:white;
   text-align:center;
   justify-content:center;
   opacity:0; 
}

关于html - CSS Transition 没有相应地工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30880597/

相关文章:

android - 如何将 imageView 设置为不固定在某个位置

javascript - AngularJS Bootstrap 导航栏

javascript - 在 AngularJS 和 Jade 中使用无限滚动

html - 取决于宽度的相等div?

jquery - 像 Firebug 一样检查 html 元素

html - 单击转换 <ul> 没有响应

javascript - Express:模板引擎 (Pug) 调用的样式/脚本未加载

javascript - 如何在网站的移动视口(viewport)中显示可折叠菜单?

php - 在 web2py 中保留文件上传 html 表单

css - 防止溢出 :hidden from cropping the image