【问题标题】:CSS3: hide overflow for transform effectCSS3:隐藏变形效果的溢出
【发布时间】:2013-12-27 09:31:30
【问题描述】:

我正在尝试在图像上制作一个简单的 CSS3 悬停效果。我正在尝试将图像的一半显示为透明。为了更容易看到问题,我将其设置为黑色。

<div class="section">
    <img src="http://placekitten.com/110/155" />
    <div class="efx" />
</div>

.section{
    width:700px;
    background-color:orange;
    height:170px;
    position:relative;
    margin:50px;
}

.section:hover .efx{
    height:155px;
}

img{
    width:110px;
    height:155px;
}

.efx{
    overflow:hidden;
    background-color: black;
    z-index: 10;
    left: -51px;
    position: absolute;
    height: 0px;
    width: 105px;
    transition: all .5s ease-in;
    transform: skew(35deg, 0deg);
    bottom:15px;   
}

如果您查看这里的小提琴http://jsfiddle.net/5ST86/,您可以看到结果是什么。以下是我想要实现的目标。

【问题讨论】:

    标签: css css-transitions css-transforms


    【解决方案1】:

    只需将overflow:hidden 添加到section 元素即可。

    jsFiddle example

    .section{
        width:700px;
        background-color:orange;
        height:170px;
        position:relative;
        margin:50px;
        overflow:hidden;
    }
    

    【讨论】:

    • 谢谢乔希。在这种情况下,您会推荐什么? jsfiddle.net/5ST86/3我真的不能改变太多的标记。在我看来,这是一件无法破解的简单事情:(
    猜你喜欢
    • 2016-03-21
    • 1970-01-01
    • 2012-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多