溢出:隐藏;关于过渡元素

时间:2013-02-07 12:00:18

标签: overflow css-transitions css3

正如您所见here(小提琴),a是父级,并设置为overflow: hidden;span是孩子,并设置box-shadow。当没有任何事情发生时,一切顺利,但当用户悬停a时,其overflow属性似乎被覆盖(即阴影显示为正方形,而不是圆形,应该如此) 。知道如何解决这个问题吗?

代码: 的 HTML

<a href="#" title="Hover me"><span>Hover me</span></a>

CSS

a {
    overflow: hidden;
    width: 52px;
    height: 52px;
    top: 0;
    display: block;
    position: relative;
    margin: 50px;
    background: red;

    -webkit-transition: all 300ms linear;
    -moz-transition: all 300ms linear;
    -ms-transition: all 300ms linear;
    -o-transition: all 300ms linear;
    transition: all 300ms linear;

    border-radius: 200px;
    opacity: 0.6;
}

a:hover {
    opacity: 1;
    top: -8px;
}

a > span {
    width: 100%;
    height: 100%;
    display: block;
    box-shadow: inset 0 -35px 10px rgba(0,0,0,0.8);
}

a:hover > span {
    box-shadow: inset 0 -28px 10px rgba(0,0,0,0.8);
}

1 个答案:

答案 0 :(得分:0)

你的问题并不明白,但试试这个,如果它可以帮助你那么......

a {
    overflow: hidden;
    width: 52px;
    height: 52px;
    top: 0;
    display: block;
    position: relative;
    margin: 50px;
    background: red;

    -webkit-transition: all 300ms linear;
    -moz-transition: all 300ms linear;
    -ms-transition: all 300ms linear;
    -o-transition: all 300ms linear;
    transition: all 300ms linear;

    border-radius: 200px;
    opacity: 0.6;
}

a:hover {
    overflow: hidden;
    opacity: 1;
}

a > span {
    overflow: hidden;
    width: 100%;
    height: 100%;
    display: block;
    box-shadow: inset 0 -35px 10px rgba(0,0,0,0.8);
}

a:hover > span {
    overflow: hidden;
    box-shadow: inset 0 -28px 10px rgba(0,0,0,0.8);
}