CSS3 背景图像悬停过渡

标签 css animation hover background-image transition

请检查以下链接

http://intelmarketing.mk/demos/security/services/

你会连续看到 3 个图标,几乎所有悬停都有 css3 转换,但我无法将动画添加到我尝试过几个例子的图标上,比如

http://css3.bradshawenterprises.com/cfimg/ - 示例 1

但是没有接缝工作,而且我的图像是透明的,所以示例 1 没有按我想要的方式工作,所以我想要的是当我将鼠标悬停在框上时,按钮和图标同时平滑地悬停,按钮工作但是图标没有 我该如何解决这个问题?

第一个图标的CSS:

.fastvagticon
{
    width:299px;
    height:166px;
    margin:0 auto;
    background-image:url('images/FASTVAGT.png');
    background-repeat:no-repeat;
    background-position:center;
}

.servbox:hover .fastvagticon
{
    width:299px;
    height:166px;
    background-image:url('images/FASTVAGTh.png');
    background-repeat:no-repeat;
    margin-top:0px;
}

按钮的CSS

.servbtn1
{
    background-color:transparent;
    background-position: right center;
    background-image: url("images/eempy.png");
    background-repeat: no-repeat;
    color: #FFFFFF;
    height: 34px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 35px;
    padding-top: 8px;
    text-align: left;
    width: 151px;
      -webkit-transition: all 1s ease;
      -moz-transition: all 1s ease;
      -ms-transition: all 1s ease;
      -o-transition: all 1s ease;
      transition: all 1s ease;
      border:1px solid #fff;
}

.servbox:hover .servbtn1
{
    width:184px;
    height:34px;
    background-color:#3E1C1E;
    background-repeat: no-repeat;
    color: #FFFFFF;
    margin-left: auto;
    margin-right: auto;
    padding-left: 35px;
    padding-top: 8px;
    text-align: left;
    width: 151px;
}

最佳答案

您没有向图标添加任何过渡:

.fastvagticon
{
    width:299px;
    height:166px;
    margin:0 auto;
    background-image:url('images/FASTVAGT.png');
    background-repeat:no-repeat;
    background-position:center;

    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -ms-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}

此外,我不知道您是否知道,但这在 Firefox 中不起作用。 Firefox 不允许背景图像的任何动画。

关于CSS3 背景图像悬停过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24163180/

相关文章:

html - 使 DIV 与内联阻塞 div 的宽度相同?

html - ie8 打破 float :left into 2 rows

android - 创建布局自定义标题

html - 旋转文本 IE Microsoft.Matrix

css - 如何按顺序为模式元素设置动画?

css - 在 chrome 中滚动时 Div 悬停不起作用

css - 防止悬停在绝对定位的 child 上以传播给 parent

macos - CGAffineTransformMakeScale 不工作 - OS X - Cocoa

javascript - 如何在 JS 中制作雪花飘落的动画?

php - 如何通过任何爬虫php获取悬停数据(ajax)