首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >伪元素上的转换:after和: working working

伪元素上的转换:after和: working working
EN

Stack Overflow用户
提问于 2014-11-07 18:08:05
回答 1查看 275关注 0票数 0

我知道以前有人问过这个问题,但我有一个具体的问题,我似乎不能使用其他问题中回答的解决方案。

我有一个缩略图,上面有一个:after play图标,只在悬停时显示它是一个视频,但不透明度转换不只对图像有效。

有人知道解决方案吗?

代码语言:javascript
运行
复制
.play-icon:hover:after {
position:absolute;
cursor: pointer;
top:0; 
left:0;
content:'';
width: 100%;
height: 100%;
background: url("http://www.kiddyjunction.ca/support/images/ilightbox/light-skin/thumb-overlay-play.png");
background-repeat: no-repeat;
background-position: center center;
background-color: transparent;   
z-index: 9999;
}

这里是fiddle

EN

回答 1

Stack Overflow用户

发布于 2014-11-07 18:11:29

我假设这里的<img>就是您想要的动画,所以添加一个过渡样式到该元素:

代码语言:javascript
运行
复制
:hover {
    text-decoration: none;
    -webkit-transition: all 0.2s ease-in-out;
       -moz-transition: all 0.2s ease-in-out;
        -ms-transition: all 0.2s ease-in-out;
         -o-transition: all 0.2s ease-in-out;
            transition: all 0.2s ease-in-out;
}
.play-icon:hover:after {
    position:absolute;
    cursor: pointer;
    top:0;
    left:0;
    content:'';
    width: 100%;
    height: 100%;
    background: url("http://www.kiddyjunction.ca/support/images/ilightbox/light-skin/thumb-overlay-play.png");
    background-repeat: no-repeat;
    background-position: center center;
    background-color: transparent;
    z-index: 9999;
}
.thumb-grid {
    display: block;
    width: 100%;
    padding: 0 0 0 0;
    margin: 5em 0 2.5em 0;
    list-style-type: none;
    background-color: transparent;
}
.thumb-grid:after {
    content:'';
    width: 0;
    display: block;
    clear: both;
}
.thumb-grid li {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    width: 13%;
    margin: 0 8.75% 0 0;
    display: block;
    float: left;
    padding-bottom: 13%;
}
.thumb-grid li:nth-child(5n) {
    margin-right: 0;
}
.thumb-grid img {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
    /* Firefox 3.5+ */
    filter: gray;
    /* IE6-9 */
    -webkit-filter: grayscale(100%);
    /* Chrome 19+ & Safari 6+ */
    -webkit-transition: all 0.2s ease-in-out;
       -moz-transition: all 0.2s ease-in-out;
        -ms-transition: all 0.2s ease-in-out;
         -o-transition: all 0.2s ease-in-out;
            transition: all 0.2s ease-in-out;
}
.thumb-grid li:hover img {
    opacity: 0.5;
}
代码语言:javascript
运行
复制
<ul class="thumb-grid">
    <li id="gallery" class="play-icon">
        <img src="http://placehold.it/250x250" />
    </li>
    <li>
        <img src="http://placehold.it/250x250" />
    </li>
    <li>
        <img src="http://placehold.it/250x250" />
    </li>
    <li>
        <img src="http://placehold.it/250x250" />
    </li>
    <li>
        <img src="http://placehold.it/250x250" />
    </li>
</ul>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26798749

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档