之前刚学完CSS时,写的一段代码,花了七八个小时才写完,定位太花时间了。网上有很多版本,但这是原汁原味的新手写法。支持谷歌火狐IE,手机的自带浏览器也支持,附上代码。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>哆啦A梦</title> <style type="text/css"> .entirety{ width: 500px; height: 680px; border:1px solid black; position: absolute; left: 0; right: 0; margin: auto; } .head{ width: 300px; height: 300px; border-radius: 150px; border: 2px solid #333; background-image: -webkit-radial-gradient(99% 1%, #fff , #0C99C7 75%, black 100%); background-image: -moz-radial-gradient(99% 1%, #fff , #0C99C7 75%, black 100%); background-image: -ms-radial-gradient(99% 1%, #fff , #0C99C7 75%, black 100%); box-shadow: -5px 5px 15px 2px #888 ; position: absolute; left: 0; right: 0; margin: auto; } .face{ width: 250px; height: 210px; border-radius: 175px; background-color: #fff; position: relative; left: 25px; top: 65px; } .left_eye{ width: 60px; height: 70px; border-radius: 30px; border: 2px solid black; background-color: #fff; position: relative; top: -170px; left: 87px; } .left_eyeball{ width: 12px; height: 12px; border-radius: 6px; background-color: black; position: relative; top:10px; left:40px; -webkit-animation-name: cat; -webkit-animation-duration: 2s; -webkit-animation-timing-function: linear; -webkit-animation-fill-mode: backwards; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: alternate; } .right_eye{ width: 60px; height: 70px; border-radius: 30px; border: 2px solid black; background-color: #fff; position: relative; top: -242px; left: 149px; } .right_eyeball{ width: 12px; height: 12px; border-radius: 6px; background-color: black; position: relative; top:8px;