這是一個相當有趣的 CSS3 動畫範例:完全不用 JavaScript 或圖片序列,僅憑 CSS3 的 @keyframes 動畫與 transform,就能讓一個由多層 div 組成的小人做出走路的動作,就連天空的雲朵飄動、地面的佈景也一併以純 CSS 呈現。
請使用支援 CSS3(HTML5)的瀏覽器,例如 Chrome 或 Firefox 觀看效果:
https:///keleyi/phtml/html5/6.htm
效果示意圖:

其做法是將小人的軀幹、大腿、小腿、手臂等部位各自獨立成元素,再分別套用不同角度與節奏的 keyframes 動畫,藉此模擬出自然的擺動姿態。以下為完整原始碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>純CSS3實現人走路動畫</title>
<link rel="stylesheet" href="https:///keleyi/phtml/html5/6/webkit_keyframes.css" type="text/css">
<link rel="stylesheet" href="https:///keleyi/phtml/html5/6/moz_keyframes.css" type="text/css">
<link rel="stylesheet" href="https:///keleyi/phtml/html5/6/common.css" type="text/css">
</head>
<body>
<div id="canvas">
<div class="sky"></div>
<div class="horizon"></div>
<div class="ground"></div>
<div class="shadow"></div>
<div class="me">
<div class="torso">
<div class="left leg"><div class="left thigh"><div class="left shin"><div class="left foot"><div class="left toes"></div></div></div></div></div>
<div class="right leg"><div class="right thigh"><div class="right shin"><div class="right foot"><div class="right toes"></div></div></div></div></div>
<div class="left arm"><div class="left bicep"><div class="left forearm"></div></div></div>
<div class="right arm"><div class="right bicep"><div class="right forearm"></div></div></div>
</div>
<div class="overlay"></div>
</div>
</body>
</html>