小编Sup*_*ose的帖子

当悬停图像时,css在块文本的过渡中淡入淡出?

所以这是我的代码,当我悬停图像时,我希望使用css3过渡淡入文本和背景颜色.我已经尝试了很多选择器和过渡类型,但似乎无法得到任何帮助非常感谢.

见下面的演示

http://jsfiddle.net/jiceb/xsFmA/

<a href="#">
      <h2>Some Text</h2>
      <img src="http://www.sheridanrogers.com.au/wp-content/uploads/2011/03/American-pancakes.jpg"/>
</a>
Run Code Online (Sandbox Code Playgroud)

和css

a { position: relative; display: inline-block }

a img {
    width:250px;
}

a h2 {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    background: black;
    color: #fff;
}

a:hover h2 {
    display: block;
}
Run Code Online (Sandbox Code Playgroud)

html css fade css3 css-transitions

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

css ×1

css-transitions ×1

css3 ×1

fade ×1

html ×1