【问题标题】:delaying the hover of background- image [duplicate]延迟背景图像的悬停[重复]
【发布时间】:2015-09-30 02:50:05
【问题描述】:

CSS

.navbar-brand {
  display: block;
  margin: 0; padding: 0;
  height: 80px;
  width: 70px;
  background: url('img/logo_orig.png') no-repeat center center;
  background-size: 100% auto;
}

.navbar-brand:hover {
  background: url('img/logo_hov.png') no-repeat center center;
  background-size: 100% auto;
}

这会创建一个带有背景图像的按钮,当它悬停时会显示背景。

我想在悬停时为背景图像添加延迟。类似于使用

transition: background-color 0.35s ease;

【问题讨论】:

  • background-image 还不是动画属性。您可能需要在这里重新考虑。

标签: html css


【解决方案1】:

你可以使用这样的东西。

HTML:

#cf {
  position: relative;
  height: 281px;
  width: 450px;
  margin: 0 auto;
}
#cf img {
  position: absolute;
  left: 0;
  -webkit-transition: opacity 1s ease-in-out;
  -moz-transition: opacity 1s ease-in-out;
  -o-transition: opacity 1s ease-in-out;
  transition: opacity 1s ease-in-out;
  height:inherit;
  width:inherit;
}
#cf img.top:hover {
  opacity: 0;
}
<div id="cf">
  <img class="bottom" src="http://www.psdgraphics.com/file/colorful-triangles-background.jpg" />
  <img class="top" src="http://cdp.pasctunisie.org/wp-content/uploads/2015/05/light-circles-wave-powerpoint-backgrounds.jpg" />
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-12
    • 2018-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-11
    • 2013-01-27
    相关资源
    最近更新 更多