jquery - 图像上的 CSS 过渡不起作用

标签 jquery css wordpress image transition

在我网站的顶部,我有一个画廊,当您向下滚动页面时,我希望画廊以较小的版本显示。

大版本:

http://i.imgur.com/M8vUnnQ.png

小版本:

http://i.imgur.com/xS0G25Z.png

我用 jQuery 做了这个,当你滚动 300 像素(画廊初始高度)时,你会得到大约 100 像素高度的小的。

我已经设置了一些转换:

初始:

#gallery {
  overflow: hidden;
  width: 100%;
  height: 305px;
  white-space: nowrap;
  vertical-align: middle;
  display: inline-block;
  background-color:white;
  -webkit-transition: all ease 0.5s;
  transition: all ease 0.5s;
}
#gallery img {
  height: 300px;
  width: auto;
  padding: 2px;
  vertical-align: middle;
  -webkit-transition: all ease 0.5s;
  transition: all ease 0.5s;
}

滚动:

#fixed_gallery {
  overflow: hidden !important;
  width: 100% !important;
  white-space: nowrap !important;
  vertical-align: middle !important;
  display: inline-block !important;
  position: fixed !important;
  z-index: 53 !important;
  height: 100px !important;
  background-color:white;
  -webkit-transition: all ease 0.5s;
  transition: all ease 0.5s;
}

#fixed_gallery img {
  height: 95px !important;
  width: auto !important;
  padding: 2px !important;
  -webkit-transition: all ease 0.5s;
  transition: all ease 0.5s;
}

我有相同的导航箭头代码,它们确实随着过渡缩放。我有点迷失了这个:\!

如何让这种转变发挥作用?因此,当画廊变成小版本时,我希望图像变小并有一个很好的过渡。

引用网址:http://ehad.mediaheads.nl/blog/ & http://jsfiddle.net/fzjqyhcw/

最佳答案

图像上的 css 转换不起作用,因为您实际上并未调整图像的大小。

尝试添加一个类(而不是切换父类的 ID)以便您可以执行如下操作:

#gallery {
   ...
   position: relative;
}

#gallery img {
   ...
  -webkit-transition: all ease 0.5s;
  transition: all ease 0.5s;
}

#gallery.fixed-gallery {
   ....
   position: fixed;
}

#gallery.fixed-gallery img {
   ....
   height: 95px;
}

关于jquery - 图像上的 CSS 过渡不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27399001/

相关文章:

javascript - Smooth Scroll 跳跃而不是滚动

php - 将 Wordpress 中的 CSS 与 PHP 和 bloginfo() 链接起来

jquery - 带进度条的菜单

jQuery 使用 .filter() 作为 .addClass()

javascript - 使用 JQuery 保存每个变量的计数

javascript - WordPress 中的屏幕选项不适用于新的自定义元框

css - 无法将 div 类居中

jquery - 调整位置 :Fixed div to make it responsive/fluid 的宽度

javascript - Rails 中带有 'Next' 和 'Previous' 按钮的表单 (Javascript)

ios - CSS 动画变换 : translate poor performance on iPad