Css3过渡 - 悬停覆盖元素

时间:2015-10-14 07:44:54

标签: html css css3 css-transitions

我想在容器悬停时在元素上制作简单的动画。我不知道应该用CSS语法编写它。

<article class="col-md-4 offer-box">
                            <div class="media">
                              <div class="media-left">
                                  <i id="icon" class="fa fa-paint-brush"></i>
                              </div>
                              <div class="media-body">
                                  <h4 class="media-heading" id="text-light">Web Design</h4>
                                <p class="text-muted">Pellentesque habitant 
                                    morbi tristique senectus et netus et
                                    malesuada fames ac turpis egestas. 
                                    Vestibulum tortor quam, feugiat vitae,
                                    ultricies eget, tempor sit amet, ante.
                                    Donec eu libero sit amet quam egestas 
                                    semper. Aenean ultricies mi vitae est.
                                    Mauris placerat eleifend leo.</p>
                              </div>
                            </div>
                        </article>

#icon{
    color: #ef5925;
    font-size: 35px;
    transition-duration: 1s;
}
.offer-box:hover{
    #icon{
    color: #fff;
    font-size: 40px;   
    }
}

1 个答案:

答案 0 :(得分:1)

您的css语法错误。写得像这样:

.offer-box:hover #icon{
    color: #fff;
    font-size: 40px;   
}

jsFiddle:http://jsfiddle.net/AndrewL32/65sf2f66/72/