<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS3做的球形动效</title>
<style>
body {
position: absolute;
top: 0;
bottom: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 100%;
overflow: hidden;
background: #bfb4b2;
}
.sphere {
position: relative;
width: 80vmin;
height: 80vmin;
border-radius: 50%;
background-image: -webkit-linear-gradient(bottom left, #947c7b, #c2bab7);
background-image: linear-gradient(bottom left, #947c7b, #c2bab7);
}
.sphere:before {
display: block;
content: '';
position: absolute;
bottom: 1%;
right: 28%;
height: 16%;
width: 80%;
border-radius: 50% 0 70% 80%/100%;
background: #5d3f3d;
box-shadow: 0px 1vmin 1.5vmin #5d3f3d, -2vmin 0vmin 4vmin #5d3f3d, -5vmin 0vmin 6vmin #5d3f3d, -5vmin 0vmin 10vmin #5d3f3d;
z-index: -10;
}
.sphere:after {
display: block;
content: '';
position: absolute;
left: -50%;
bottom: -5%;
width: 100%;
height: 40%;
background: -webkit-linear-gradient(left, #bfb4b2, rgba(191, 180, 178, 0) 75%);
background: linear-gradient(to right, #bfb4b2, rgba(191, 180, 178, 0) 75%);
z-index: -5;
}
.sphere .cast-shadow {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
background-image: url(images/sphere-shadow-tiny.png);
background-repeat: no-repeat;
background-size: cover;
mix-blend-mode: soft-light;
}
.sphere .cast-shadow:before {
display: block;
content: '';
position: absolute;
width: 100%;
height: 100%;
background-image: url(images/sphere-shadow-tiny.png);
background-repeat: no-repeat;
background-size: cover;
mix-blend-mode: darken;
opacity: .4;
}
.sphere .cast-shadow:after {
display: block;
content: '';
position: absolute;
width: 100%;
height: 100%;
background-image: url(images/sphere-highlight-tiny.png);
background-repeat: no-repeat;
background-size: cover;
mix-blend-mode: overlay;
}
.mini-sphere {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
height: .1rem;
width: 84vmin;
margin: 0;
}
.mini-sphere:after {
display: block;
content: '';
position: absolute;
top: 50%;
right: 0;
width: 6vmin;
height: 6vmin;
margin-right: 0;
border-radius: 50%;
background: white;
background-size: cover;
box-shadow: 0px 4px 4px #5d3f3d;
opacity: 0;
background-image: url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAQDAwMDAgQDAwMEBAQFBgoGBgUFBgwICQcKDgwPDg4MDQ0PERYTDxAVEQ0NExoTFRcYGRkZDxIbHRsYHRYYGRj/2wBDAQQEBAYFBgsGBgsYEA0QGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBj/wgARCAAKAAoDAREAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAABwMI/8QAFwEAAwEAAAAAAAAAAAAAAAAAAAMEAv/aAAwDAQACEAMQAAAA0Ai2gDxSn7X/AP/EACMQAAIBAwMEAwAAAAAAAAAAAAECAwAEBQYREgcTIVEiQWH/2gAIAQEAAT8A6eZ3T9/i8hPkrmFL8TuHEh48FB8AegBR1Bi2YtDDNLGTujqhIYfRFXEELans+UMZ7sqiTdR8x++6aSRHKI7KqnYAHYAV/8QAFhEBAQEAAAAAAAAAAAAAAAAAEQAQ/9oACAECAQE/AGN//8QAGREAAgMBAAAAAAAAAAAAAAAAAQIAAxAS/9oACAEDAQE/AHrKmcnf/9k=");
background-repeat: no-repeat;
background-size: cover;
}
@-webkit-keyframes animate1 {
0% {
-webkit-transform: translate3d(0, -50%, 0) rotate(-22.5deg);
transform: translate3d(0, -50%, 0) rotate(-22.5deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
50% {
height: 10vmin;
width: 10vmin;
margin-right: -2.5vmin;
}
100% {
-webkit-transform: translate3d(-78vmin, -50%, 0) rotate(-22.5deg);
transform: translate3d(-78vmin, -50%, 0) rotate(-22.5deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
}
@keyframes animate1 {
0% {
-webkit-transform: translate3d(0, -50%, 0) rotate(-22.5deg);
transform: translate3d(0, -50%, 0) rotate(-22.5deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
50% {
height: 10vmin;
width: 10vmin;
margin-right: -2.5vmin;
}
100% {
-webkit-transform: translate3d(-78vmin, -50%, 0) rotate(-22.5deg);
transform: translate3d(-78vmin, -50%, 0) rotate(-22.5deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
}
@-webkit-keyframes show1 {
0% {
opacity: 0;
}
50%,
100% {
opacity: 1;
}
}
@keyframes show1 {
0% {
opacity: 0;
}
50%,
100% {
opacity: 1;
}
}
.mini-sphere:nth-of-type(1) {
-webkit-transform: translate3d(-50%, -50%, 0) rotate(22.5deg);
transform: translate3d(-50%, -50%, 0) rotate(22.5deg);
}
.mini-sphere:nth-of-type(1):after {
-webkit-transform: translate3d(0, -50%, 0) rotate(-22.5deg);
transform: translate3d(0, -50%, 0) rotate(-22.5deg);
-webkit-animation: animate1 2s 0.25s linear infinite alternate, show1 2s 0.25s ease-in forwards;
animation: animate1 2s 0.25s linear infinite alternate, show1 2s 0.25s ease-in forwards;
}
@-webkit-keyframes animate2 {
0% {
-webkit-transform: translate3d(0, -50%, 0) rotate(-45deg);
transform: translate3d(0, -50%, 0) rotate(-45deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
50% {
height: 10vmin;
width: 10vmin;
margin-right: -2.5vmin;
}
100% {
-webkit-transform: translate3d(-78vmin, -50%, 0) rotate(-45deg);
transform: translate3d(-78vmin, -50%, 0) rotate(-45deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
}
@keyframes animate2 {
0% {
-webkit-transform: translate3d(0, -50%, 0) rotate(-45deg);
transform: translate3d(0, -50%, 0) rotate(-45deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
50% {
height: 10vmin;
width: 10vmin;
margin-right: -2.5vmin;
}
100% {
-webkit-transform: translate3d(-78vmin, -50%, 0) rotate(-45deg);
transform: translate3d(-78vmin, -50%, 0) rotate(-45deg);
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
}
}
@-webkit-keyframes show2 {
0% {
opacity: 0;
}
50%,
100% {
opacity: 1;
}
}
@keyframes show2 {
0% {
opacity: 0;
}
50%,
100% {
opacity: 1;
}
}
.mini-sphere:nth-of-type(2) {
-webkit-transform: translate3d(-50%, -50%, 0) rotate(45deg);
transform: translate3d(-50%, -50%, 0) rotate(45deg);
}
.mini-sphere:nth-of-type(2):after {
-webkit-transform: translate3d(0, -50%, 0) rotate(-45deg);
transform: translate3d(0, -50%, 0) rotate(-45deg);
-webkit-animation: animate2 2s 0.5s linear infinite alternate, show2 2s 0.5s ease-in forwards;
animation: animate2 2s 0.5s linear infinite alternate, show2 2s 0.5s ease-in forwards;
}
@-webkit-keyframes animate3 {