--- title: animation-fill-mode slug: Web/CSS/animation-fill-mode tags: - CSS 속성 - CSS 애니메이션 translation_of: Web/CSS/animation-fill-mode --- <div>{{CSSRef}}</div> <p><strong><code>animation-fill-mode</code></strong> <a href="/en/CSS" title="CSS">CSS</a> 속성은 CSS 애니메이션이 실행 전과 후에 대상에 스타일을 적용하는 방법을 지정합니다.</p> <pre class="brush: css no-line-numbers">/* Single animation */ animation-fill-mode: none; animation-fill-mode: forwards; animation-fill-mode: backwards; animation-fill-mode: both; /* Multiple animations */ animation-fill-mode: none, backwards; animation-fill-mode: both, forwards, none; </pre> <p>축약 속성 <a href="https://developer.mozilla.org/ko/docs/Web/CSS/animation" title="CSS의 animation 속성은 animation-name, animation-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction 값들을 지정가능한 축약된 속성(shorthand property)이다."><code>animation</code></a>을 사용하여 모든 애니메이션 속성을 한꺼번에 설정하는 것이 편리합니다.</p> <p>{{cssinfo}}</p> <h2 id="문법(Syntax)">문법(Syntax)</h2> <h3 id="값(Values)">값(Values)</h3> <dl> <dt><code>none</code></dt> <dd>애니메이션은 실행되지 않을 때 대상에 스타일을 적용하지 않습니다. 요소는 대신 적용된 다른 CSS 규칙을 사용하여 표시됩니다. 이것은 기본값입니다.</dd> <dt><code>forwards</code></dt> <dd>대상은 실행 된 애니메이션의 마지막 <a href="https://developer.mozilla.org/en-US/docs/CSS/@keyframes">keyframe</a>에 의해 설정된 계산 된 값을 유지합니다. 마지막 키 프레임은 {{cssxref("animation-direction")}}및 {{cssxref("animation-iteration-count")}}의 값에 따라 다릅니다. <table class="standard-table"> <thead> <tr> <th scope="col"><code>animation-direction</code></th> <th scope="col"><code>animation-iteration-count</code></th> <th scope="col">last keyframe encountered</th> </tr> </thead> <tbody> <tr> <td><code>normal</code></td> <td>even or odd</td> <td><code>100%</code> or <code>to</code></td> </tr> <tr> <td><code>reverse</code></td> <td>even or odd</td> <td><code>0%</code> or <code>from</code></td> </tr> <tr> <td><code>alternate</code></td> <td>even</td> <td><code>0%</code> or <code>from</code></td> </tr> <tr> <td><code>alternate</code></td> <td>odd</td> <td><code>100%</code> or <code>to</code></td> </tr> <tr> <td><code>alternate-reverse</code></td> <td>even</td> <td><code>100%</code> or <code>to</code></td> </tr> <tr> <td><code>alternate-reverse</code></td> <td>odd</td> <td><code>0%</code> or <code>from</code></td> </tr> </tbody> </table> </dd> <dt><code>backwards</code></dt> <dd>애니메이션은 대상에 적용되는 즉시 첫 번째 관련 <a href="/en-US/docs/CSS/@keyframes">keyframe</a> 에 정의 된 값을 적용하고 {{cssxref("animation-delay")}} 기간 동안 이 값을 유지합니다. 첫 번째 관련 키프레임은 {{cssxref("animation-direction")}}의 값에 따라 다릅니다. <table class="standard-table"> <thead> <tr> <th scope="col"><code>animation-direction</code></th> <th scope="col">first relevant keyframe</th> </tr> </thead> <tbody> <tr> <td><code>normal</code> or <code>alternate</code></td> <td><code>0%</code> or <code>from</code></td> </tr> <tr> <td><code>reverse</code> or <code>alternate-reverse</code></td> <td><code>100%</code> or <code>to</code></td> </tr> </tbody> </table> </dd> <dt><code>both</code></dt> <dd>애니메이션은 앞뒤 양쪽 모두의 규칙을 따르므로 애니메이션 속성이 양방향으로 확장됩니다.</dd> </dl> <div class="note"> <p><span style="font-size: 14px;"><strong>노트</strong></span>: animation- * 속성에 여러 개의 쉼표로 구분 된 값을 지정하면 <a href="https://developer.mozilla.org/ko/docs/Web/CSS/animation-name" title="The documentation about this has not yet been written; please consider contributing!"><code>animation-name</code></a> 속성에 지정된 애니메이션에 할당되는 값의 수에 따라 다른 방식으로 지정됩니다. 자세한 내용은 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations#Setting_multiple_animation_property_values">여러 애니메이션 속성 값 설정</a>을 참조하십시오.</p> </div> <h3 id="Formal_syntax">Formal syntax</h3> {{csssyntax}} <h2 id="Example" name="Example">예제(Examples)</h2> <p>다음 예제에서 animation-fill-mode의 효과를 볼 수 있습니다. 무한 시간 동안 실행되는 애니메이션의 경우 원래 상태 (기본값)로 되돌리기보다는 최종 상태로 유지하는 방법을 보여줍니다.</p> <h3 id="HTML">HTML</h3> <pre class="brush: html"><p>회색 박스 위에 마우스를 올려보세요!</p> <div class="demo"> <div class="grows">이 글씨는 커집니다.</div> <div class="growsandstays">이 글씨는 커지며, 커진 상태를 유지합니다.</div> </div></pre> <h3 id="CSS">CSS</h3> <pre class="brush: css">.demo { border-top: 100px solid #ccc; height: 300px; } @keyframes grow { 0% { font-size: 0; } 100% { font-size: 40px; } } .demo:hover .grows { animation-name: grow; animation-duration: 3s; } .demo:hover .growsandstays { animation-name: grow; animation-duration: 3s; animation-fill-mode: forwards; }</pre> <p>{{EmbedLiveSample('Example',700,300)}}</p> <p>자세한 예제는 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations" title="CSS/CSS_animations">CSS animations</a>를 보십시오.</p> <h2 id="Specifications" name="Specifications">명세(Specifications)</h2> <table class="standard-table"> <thead> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('CSS3 Animations', '#animation-fill-mode', 'animation-fill-mode')}}</td> <td>{{Spec2('CSS3 Animations')}}</td> <td>Initial definition.</td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">브라우저 호환성(Browser compatibility)</h2> <p>{{CompatibilityTable}}</p> <div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Edge</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari (WebKit)</th> </tr> <tr> <td>Basic support</td> <td>{{CompatVersionUnknown}}{{property_prefix("-webkit")}}<br> {{CompatChrome(43.0)}}</td> <td>{{CompatVersionUnknown}}{{property_prefix("-webkit")}}<br> {{CompatVersionUnknown}}</td> <td>{{CompatGeckoDesktop("5.0")}}{{property_prefix("-moz")}}<br> {{CompatGeckoDesktop("16.0")}}<sup>[1]</sup></td> <td>10</td> <td>12{{property_prefix("-o")}}<br> 12.10</td> <td>4.0{{property_prefix("-webkit")}}</td> </tr> </tbody> </table> </div> <div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Chrome</th> <th>Edge</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> <th>Chrome for Android</th> </tr> <tr> <td>Basic support</td> <td>{{CompatUnknown}}</td> <td>{{CompatUnknown}}</td> <td>{{CompatVersionUnknown}}{{property_prefix("-webkit")}}<br> {{CompatVersionUnknown}}</td> <td>{{CompatUnknown}}</td> <td>{{CompatUnknown}}</td> <td>{{CompatUnknown}}</td> <td>{{CompatUnknown}}</td> <td>{{CompatUnknown}}</td> </tr> </tbody> </table> </div> <p>[1] Gecko 44.0 {{geckoRelease("44.0")}} 은 layout.css.prefixes.webkit 환경 설정 뒤에 웹 호환성 이유로 인해 -webkit- 접두사가 붙은 속성 버전에 대한 지원을 추가했으며, 기본값은 false입니다. Gecko 49.0 {{geckoRelease("49.0")}} 이후 기본 설정은 true로 기본 설정됩니다.</p> <h2 id="같이_보기(See_also)">같이 보기(See also)</h2> <ul> <li><a href="/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations" title="Tutorial about CSS animations">Using CSS animations</a></li> <li>JavaScript {{domxref("AnimationEvent")}} API</li> </ul>