2017-05-24 3 views
0

내 웹 사이트 로고를 빛낼 코드를 씁니다. 로고 위에 마우스를 가져 가면 작동하지만 웹 사이트를로드 할 때 무한대의 애니메이션 자동 재생을 원합니다. 키 프레임을 사용하지만 작동하지 않으며 혼란 스럽습니다.CSS hover 애니메이션을 자동 애니메이션으로 변환합니다.

내 CSS 코드 :

@import url(https://fonts.googleapis.com/css?family=Raleway); 
 
html{ 
 
    font: .9em 'Raleway',sans-serif; 
 
    height: 100%; 
 
    text-align: center; 
 
    background: radial-gradient(50% 0,rgba(255,255,255,.3),rgba(255,255,255,0)), deepskyblue; 
 
    color: rgba(0,0,0,.6); 
 
} 
 
p a{ 
 
    color: rgba(0,0,0,.6); 
 
} 
 
.mask a{ 
 
    position: relative; 
 
    display:block; 
 
    width:150px; 
 
    height: 64px; 
 
    text-align:center; 
 
    margin: 50px auto; 
 
    background: ; 
 
    -webkit-filter: drop-shadow(1px 1px 2px rgba(0,0,0,.5)); 
 
} 
 
.mask a{ 
 
    background-position: -140px 0; 
 
    
 
} 
 
.mask a:hover, 
 
.mask a:focus{ 
 
    background-position: 10px 0; 
 
    /*change speed to see in slow motion*/ 
 
    transition: all 1s; 
 
} 
 
.mask a::after{ 
 
    content:''; 
 
    position: absolute; 
 
    pointer-events: none; 
 
    top:0; left:0; right:0; bottom: 0; 
 
    background: radial-gradient(0 0,circle farthest-side, rgba(255,255,255,0) 90%,rgba(255,255,255,.8) 98%,rgba(255,255,255,0) 100%) no-repeat; 
 
    background: radial-gradient(circle farthest-side at 0 0, rgba(255,255,255,0) 90%,rgba(255,255,255,.8) 98%,rgba(255,255,255,0) 100%) no-repeat; 
 
    background-position: inherit; 
 
    -webkit-mask: url('http://dev.iamvdo.me/newLogoCSS3create2.png') center; 
 
    mask: url('#mask-firefox'); 
 
}
<div class="mask pseudo"> 
 
    <a href="http://css3create.com"> 
 
    <img src="http://dev.iamvdo.me/newLogoCSS3create2.png" alt="CSS3Create logo" /> 
 
    </a> 
 
</div> 
 

 

 
<svg height="0"> 
 
    <!-- THE mask --> 
 
    <mask id="mask-firefox"> 
 
    <image width="150" height="64" xlink:href="http://dev.iamvdo.me/newLogoCSS3create2.png" filter="url(#filter)" /> 
 
    </mask> 
 
    
 
    <!-- the filter to make the image white --> 
 
    <filter id="filter"> 
 
    <feFlood flood-color="white" /> 
 
    <feComposite in2="SourceAlpha" operator="in" /> 
 
    </filter> 
 
</svg>

답변

1

반복 카운트 부정사와 shineFx라는 이름의 애니메이션을 선언이 예를보고하십시오.

.mask a{ 
    position: relative; 
    display:block; 
    width:150px; 
    height: 64px; 
    text-align:center; 
    margin: 50px auto; 
    -webkit-filter: drop-shadow(1px 1px 2px rgba(0,0,0,.5)); 
    animation-name: shineFx; 
    animation-duration: 3s; 
    animation-timing-function: ease-out; 
    animation-iteration-count: infinite; 
} 


@keyframes shineFx { 
    from {background-position: -140px 0px;} 
    to {background-position: 10px 0;} 
} 
+0

감사합니다.하지만 @keyframes 미디어의 "to :"또는 "from"에 ".mask a :: after"콘텐츠를 넣을지는 모르겠습니까? –

+0

안녕하세요 @ M.Ford! "애니메이션 ..."이라는 4 줄과 "@keyframes"로 시작하는 블록을 작업 예제에 추가합니다. 직접 시도해보십시오. 매력처럼 작동해야합니다. –