JAYbranding

CSS로 PNG 파일 애니메이션 적용하기

<style> .animatediv{ width: 951px; height: 979px; background-color: #ccc; margin: 0 auto; background-image: url('/media/2022/09/x-men-animate.png'); animation: play 1s steps(7) infinite; } @keyframes play { from { background-position: 0px; } to { background-position: -6657px; } } </style> <pre data-line=""> <code readonly="true"> <xmp> <style> .animatediv{ background-color: #ccc; margin: 0 auto; / 프레임 하나의 너비와 높이 / width: 951px; height: 979px; / 병합된 이미지의 배경 이미지 불러오기 / background-image: url('/media/2022/09/x-men-animate.png'); / 애니메이션 재생, 숫자 7을 병합된 이미지 수로 변경 / animation: play 1s steps(7) infinite; } @keyframes play { from { background-position: 0px; } / 전체 이미지의 너비로 변경 / to { background-position: -6657px; } } </style></xmp> </code> </pre>