2014-09-26 109 views
0
.box { 
    position: relative; 
    background-color: #fe0000; 
    height: 250px; 
    width: 250px; 
    border-radius: 3px; 
    overflow: hidden; 
    -moz-border-radius-bottomright: 138.88889px; 
    -webkit-border-bottom-right-radius: 138.88889px; 
    border-bottom-right-radius: 138.88889px; 
    -moz-border-radius-bottomleft: 138.88889px; 
    -webkit-border-bottom-left-radius: 138.88889px; 
    border-bottom-left-radius: 138.88889px; 
} 
.box .shine { 
    position: absolute; 
    top: -200%; 
    left: -200%; 
    width: 500px; 
    height: 500px; 
    opacity: 0; 
    background: rgba(255, 255, 255, 0.2); 
    background: -moz-linear-gradient(left, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
    background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
    background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0.2)), color-stop(75%, rgba(255, 255, 255, 0.2)), color-stop(90%, rgba(255, 255, 255, 0.8)), color-stop(100%, rgba(255, 255, 255, 0))); 
    background: -o-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
    background: -ms-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, 6 rgba(255, 255, 255, 0) 100%); 
    background: linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
    transform: rotate(30deg); 
    transition-property: left, top, opacity; 
    transition-duration: 0.5s, 0.5s, 0.1s; 
    transition-timing-function: ease-in-out; 
} 
.box:hover .shine { 
    opacity: 1; 
    top: -50%; 
    left: -50%; 
} 

http://jsfiddle.net/iaezzy/0ad7pthm/处理鼠标移开CSS效果

的光泽效果看起来不错,但如果你从元素鼠标移开,有一个奇怪的故障。我如何控制鼠标行为?

+0

你给了它在工作正常的小提琴火狐v32.0.2 – dippas 2014-09-26 12:43:15

回答

1

你无法控制通过CSS mouseout属性,但可以通过删除opacitytransition-property去除毛刺:

transition-property: left, top; 

body { 
 
    background: #444; 
 
} 
 

 
.box { 
 
    position: relative; 
 
    background-color: #fe0000; 
 
    height: 250px; 
 
    width: 250px; 
 
    border-radius: 3px; 
 
    overflow: hidden; 
 
    -moz-border-radius-bottomright: 138.88889px; 
 
    -webkit-border-bottom-right-radius: 138.88889px; 
 
    border-bottom-right-radius: 138.88889px; 
 
    -moz-border-radius-bottomleft: 138.88889px; 
 
    -webkit-border-bottom-left-radius: 138.88889px; 
 
    border-bottom-left-radius: 138.88889px; 
 
} 
 
.box .shine { 
 
    position: absolute; 
 
    top: -200%; 
 
    left: -200%; 
 
    width: 500px; 
 
    height: 500px; 
 
    opacity: 0; 
 
    background: rgba(255, 255, 255, 0.2); 
 
    background: -moz-linear-gradient(left, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
 
    background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
 
    background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0.2)), color-stop(75%, rgba(255, 255, 255, 0.2)), color-stop(90%, rgba(255, 255, 255, 0.8)), color-stop(100%, rgba(255, 255, 255, 0))); 
 
    background: -o-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
 
    background: -ms-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, 6 rgba(255, 255, 255, 0) 100%); 
 
    background: linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0) 100%); 
 
    transform: rotate(30deg); 
 
    transition-property: left, top; 
 
    transition-duration: 0.5s, 0.5s, 0.1s; 
 
    transition-timing-function: ease-in-out; 
 
} 
 
.box:hover .shine { 
 
    opacity: 1; 
 
    top: -50%; 
 
    left: -50%; 
 
}
<div class="box"> 
 
    <div class="shine"></div> 
 
</div>

+0

很酷,另一个令人讨厌的事情是,直到你徘徊在元素上,它增加了不透明性,使红色不那么明亮。我只想让闪耀穿过它走开。 – 3zzy 2014-09-26 12:47:41

+0

我;我不确定你是否可以,他们是渐变,这是如何工作的 – antyrat 2014-09-26 13:15:50