js+css3猫头鹰眼睛跟随鼠标指针转动动画特效,先来看看效果:
部分核心的代码如下(全部代码在文章末尾):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>js+css3猫头鹰眼睛跟随鼠标指针转动动画特效</title>
<style>
body {
background: #333;
}
#container {
position: relative;
height: 100%;
width: 100%;
}
#owl {
position: absolute;
left: 50%;
-webkit-transform: translate(-50%, 0%);
transform: translate(-50%, 0%);
}
#ear1_1 {
position: absolute;
width: 190px;
height: 68px;
background: #779943;
border-radius: 130px / 50px;
top: 20px;
left: 210px;
-webkit-transform: scale(0.5) rotate(-80deg);
transform: scale(0.5) rotate(-80deg);
}
#ear1_2 {
position: absolute;
width: 190px;
height: 68px;
background: #779943;
border-radius: 130px / 50px;
top: 8px;
left: 245px;
-webkit-transform: scale(0.5) rotate(45deg);
transform: scale(0.5) rotate(45deg);
}
#ear1_3 {
position: absolute;
width: 60px;
height: 60px;
background: #779943;
border-radius: 150px;
top: 37px;
left: 295px;
-webkit-transform: scale(1) rotate(45deg);
transform: scale(1) rotate(45deg);
}
#ear2_1 {
position: absolute;
width: 190px;
height: 68px;
background: #779943;
border-radius: 130px / 50px;
top: 20px;
left: 464px;
-webkit-transform: scale(0.5) rotate(80deg);
transform: scale(0.5) rotate(80deg);
}
#ear2_2 {
position: absolute;
width: 190px;
height: 68px;
background: #779943;
border-radius: 130px / 50px;
top: 8px;
left: 429px;
-webkit-transform: scale(0.5) rotate(-45deg);
transform: scale(0.5) rotate(-45deg);
}
#ear2_3 {
position: absolute;
width: 60px;
height: 60px;
background: #779943;
border-radius: 150px;
top: 37px;
left: 499px;
-webkit-transform: scale(1) rotate(-45deg);
transform: scale(1) rotate(-45deg);
}
#owl_body {
position: absolute;
width: 220px;
height: 250px;
background: #779943;
border-radius: 180px / 200px;
top: 157px;
left: 320px;
-webkit-transform: scale(2);
transform: scale(2);
}
#eye1_1 {
position: absolute;
width: 180px;
height: 180px;
background: #e7e99e;
border-radius: 150px;
top: 80px;
left: 265px;
-webkit-transform: scale(1);
transform: scale(1);
}
#eye2_1 {
position: absolute;
width: 180px;
height: 180px;
background: #e7e99e;
border-radius: 150px;
top: 80px;
left: 416px;
-webkit-transform: scale(1);
transform: scale(1);
}
#eye1_2 {
position: absolute;
width: 180px;
height: 180px;
background: #779943;
border-radius: 150px;
top: 70px;
left: 265px;
-webkit-transform: scale(0.8);
transform: scale(0.8);
}
#eye2_2 {
position: absolute;
width: 180px;
height: 180px;
background: #779943;
border-radius: 150px;
top: 70px;
left: 416px;
-webkit-transform: scale(0.8);
transform: scale(0.8);
}
#eye1_3 {
position: absolute;
width: 180px;
height: 180px;
background: #ffffff;
border-radius: 150px;
top: 70px;
left: 265px;
-webkit-transform: scale(0.67);
transform: scale(0.67);
}
#eye2_3 {
position: absolute;
width: 180px;
height: 180px;
background: #ffffff;
border-radius: 150px;
top: 70px;
left: 416px;
-webkit-transform: scale(0.67);