纯css实现3d扑克翻转特效
代码语言:html
所属分类:三维
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> html { font-size: 1vmin; background: radial-gradient(#bd243f, #190d23); } @media (min-width: 500px) { html { font-size: 5px; } } body { color: #190d23; font-size: 12rem; padding: 1rem; font-family: "Courier New"; overflow: hidden; } screen, screen *, screen *:before, screen *:after { box-sizing: border-box; content: ""; display: block; transform-style: preserve-3d; position: relative; perspective: 200rem; } card { margin: auto; height: 96rem; width: 64.5rem; background: #fff; border-radius: 5rem; transform: translate3d(0, 0, 0) rotate3d(0, 0, 0, 0) rotate(1deg); position: relative; animation: rotate 3s linear; } card *, card *:before, card *:after, card:before, card:after { position: absolute; left: 0; top: 0; } card:before, card:after { width: 100%; height: 100%; transform: translate3d(0, 0, -0.2rem) rotateY(180deg); border-radius: 5rem; animation: light 3s linear; box-shadow: inset 0 0 1rem rgba(25, 13, 35, 0.5); background-image: linear-gradient(to right bottom, rgba(25, 13, 35, 0.2), rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0), rgba(25, 13, 35, 0.3)); } card:after { transform: translate3d(0, 0, 0.2rem) rotateY(0deg); animation: light 3s linear reverse; } back { box-shadow: 0 0 0 1rem #302e9b, inset 0 0 0 1rem #302e9b, inset 0 0 0 2rem #f5e3e3; border-radius: 1rem; height: 93%; width: 90%; border: 2rem solid rgba(255, 255, 255, 0); background-position: 0.9rem 0.99rem; background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 0.99rem, #302e9b 0.99rem, #302e9b 1.98rem), repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 0.99rem, #302e9b 0.99rem, #302e9b 1.98rem); transform: translate3d(0, 0, -0.1rem) rotateY(180deg); bottom: 0; right: 0; margin: auto; } shadow { margin: auto; height: 100rem; width: 70rem; background: radial-gradient(#190d23, rgba(255, 255, 255, 0)); background: #190d23; border-radius: 10rem; position: relative; animation: shadow 3s linear; position: absolute; left: 0; right: 0; top: 0; transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(0deg) skewY(0) scale(1); opacity: 0.2; box-shadow: 0 0 2vmin #190d23, 0 0 5vmin #190d23; } hoverspace { height: 100%; width: 50rem; position: absolute; transform: translate3d(0, 0, 50rem); top: 0; left: 0; right: 0; margin: auto; cursor: grab; } hoverspace:hover ~ card { animation: rotatehover 3s linear; } hoverspace:hover ~ card:before, hoverspace:hover ~ card:after { animation: lighthover 3s linear; } hoverspace:hover ~ card:after { animation: lighthover 3s linear reverse; } hoverspace:hover ~ shadow { animation: shadowhover 3s linear; } @keyframes rotate { 100% { transform: translate3d(0, 0, 0) rotate3d(1, 1, 0, -360deg) rotate(1deg); } } @keyframes rotatehover { 100% { transform: translate3d(0, 0, 0) rotate3d(1, 1, 0, -360deg) rotate(1deg); } } @keyframes light { 0%, 100%, 50% { background-color: rgba(255, 255, 255, 0); } 25% { background-color: rgba(245, 227, 227, 0.7); } 75% { background-color: #190d23; } } @keyframes lighthover { 0%, 100%, 50% { background-color: rgba(255, 255, 255, 0); } 25% { background-color: rgba(245, 227, 227, 0.7); } 75% { background-color: #190d23; } } @keyframes shadow { 25% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(90deg) skewY(-90deg); opacity: 0; } 50% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(90deg) skewY(0); opacity: 0.2; } 75% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(90deg) skewY(90deg); opacity: 0; } 100% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(180deg) skewY(0); opacity: 0.2; } } @keyframes shadowhover { 25% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(90deg) skewY(-90deg); opacity: 0; } 50% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(90deg) skewY(0); opacity: 0.2; } 75% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(90deg) skewY(90deg); opacity: 0; } 100% { transform: translate3d(0, 90rem, -50rem) rotateX(90deg) rotate(180deg) skewY(0); opacity: 0.2; } } front { transform: translate3d(0, 0, 0.1rem) rotateY(0deg); height: 100%; width: 100%; } front > * { width: 100%; height: 100%; position: absolute; top: 0; left: 0; } front > * > *:nth-of-type(1) { transform: translate3d(2rem, 13rem, 0) scaleX(0.7); height: 4rem; width: 4rem; background: #b32b28; border-radius: 50%; box-shadow: 3.25rem 0 0 #b32b28; } front > * > *:nth-of-type(1):before { transform: translate3d(1.7rem, 1.7rem, 0) rotate(45deg); background: #b32b28; width: 4rem; height: 4rem; } front > * > *:nth-of-type(1):after { content: "K"; color: #b32b28; transform: translate3d(0, -12rem, 0); } front > * > *:nth-of-type(2) { border: 0.5rem solid #302e9b; width: 68%; height: 79.5%; bottom: 0; right: 0; margin: auto; border-radius: 0.5rem; overflow: hidden; } front > * > *:nth-of-type(2) > *:nth-of-type(6) { background: #bdb725; box-shadow: inset 0 0 0 0.1rem #fff, inset 0 0 0 0.6rem #302e9b; width: 30rem; height: 30rem; transform: translate3d(7rem, -23rem, 0) rotate(37deg) skewY(20deg); overflow: hidden; } front > * > *:nth-of-type(2) > *:nth-of-type(6):after { background: #fff; width: 40rem; height: 10rem; border-radius: 50%; transform: translate3d(4rem, 25.5rem, 0) rotate(-50deg); box-shadow: 0 0 0 1.5rem #190d23; } front > * > *:nth-of-type(2) > *:nth-of-type(6):before { width: 1.5rem; height: 1.5rem; transform: translate3d(16.5rem, 26.5rem, 0) rotate(-1deg); background: #190d23; box-shadow: 0 0 0 1.5rem #bdb725, 0 0 0 2rem #190d23, 5rem -5rem 0 #190d23, 5rem -5rem 0 1.5rem #bdb725, 5rem -5rem 0 2rem #190d23, 10rem -10rem 0 #190d23, 10rem -10rem 0 1.5rem #bdb725, 10rem -10rem 0 2rem #190d23; } front > * > *:nth-of-type(2) > *:nth-of-type(8) { transform: translate3d(0.5rem, 2.5rem, 0) scaleX(0.7); height: 8rem; width: 8rem; background: #b32b28; border-radius: 50%; box-shadow: 6.5rem 0 0 #b32b28; } front > * > *:nth-of-type(2) > *:nth-of-type(8):before { transform: translate3d(3.25rem, 3.25rem, 0) rotate(45deg); background: #b32b28; width: 8rem; height: 8rem; } front > * > *:nth-of-type(2) > *:nth-of-type(7) { width: 40rem; height: 20rem; transform: translate3d(-0.5rem, 6.5rem, 0); border-radius: 50%; overflow: hidden; } front > * > *:nth-of-type(2) > *:nth-of-type(7):after { width: 5rem; height: 14rem; border-radius: 3rem; transform: translate3d(21.5rem, -1rem, 0) rotate(-20deg) skewY(-10deg); box-shadow: 0.4rem 0.4rem 0 #302e9b, 1rem 0.8rem 0 #fff, 1.4rem 1.2rem 0 #302e9b, 2rem 1.6rem 0 #fff, 2.4rem 2rem 0 #302e9b, 3rem 2.4rem 0 #fff, 3.4rem 2.8rem 0 #302e9b, 4rem 3.2rem 0 #fff, 4.4rem 3.6rem 0 #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7):before { width: 1rem; height: 1rem; background: #fff; transform: translate3d(13.35rem, 7.85rem, 0); border-radius: 50%; box-shadow: 0.4rem 0 0 #302e9b, 0.4rem 0.4rem 0 0.3rem #fff, 0.1rem 0.4rem 0 0.6rem #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(1) { width: 3rem; height: 14rem; border-radius: 2rem; transform: translate3d(15rem, -4rem, 0) rotate(25deg); box-shadow: 0.4rem 0.4rem 0 #302e9b, 1rem 0.8rem 0 #fff, 1.4rem 1.2rem 0 #302e9b, 2rem 1.6rem 0 #fff, 2.4rem 2rem 0 #302e9b, 3rem 2.4rem 0 #fff, 3.4rem 2.8rem 0 #302e9b, 4rem 2.3rem 0 #fff, 4.4rem 2.6rem 0 #302e9b, 5rem 2rem 0 #fff, 5.4rem 2.1rem 0 #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(1):after { background: #fff; width: 10.8rem; height: 12rem; border-radius: 5rem 0 60% 2rem / 1.25rem 0 60% 5rem; transform: translate3d(1.5rem, 1rem, 0) rotate(-29deg); box-shadow: -0.4rem -0.3rem 0 #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(1):before { width: 7rem; height: 10rem; border-radius: 2.5rem; transform: translate3d(6.5rem, 4rem, 0) rotate(-55deg); border: 0.4rem solid #fff; box-shadow: 0 0 0 0.4rem #302e9b, inset 0 0 0 0.4rem #302e9b, inset 0.5rem 0 0 0.4rem #fff, inset 0.9rem 0 0 0.4rem #302e9b, inset 1.4rem 0.2rem 0 0.4rem #fff, inset 1.8rem 0.2rem 0 0.4rem #302e9b, inset 2.3rem 0.4rem 0 0.4rem #fff, inset 2.7rem 0.4rem 0 0.4rem #302e9b, inset 3.2rem 0.8rem 0 0.4rem #fff, inset 3.6rem 0.8rem 0 0.4rem #302e9b, inset -0.5rem 0 0 0.4rem #fff, inset -0.9rem 0 0 0.4rem #302e9b, inset -1.4rem 0.2rem 0 0.4rem #fff, inset -1.8rem 0.2rem 0 0.4rem #302e9b, inset -2.3rem 0.4rem 0 0.4rem #fff, inset -2.7rem 0.4rem 0 0.4rem #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(2) { width: 1.5rem; height: 1.5rem; background: #fff; transform: translate3d(25rem, 10.65rem, 0); border-radius: 50%; box-shadow: 0.4rem 0 0 #302e9b, 0.4rem 0.4rem 0 0.4rem #fff, 0.1rem 0.4rem 0 0.6rem #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(2):after { width: 1rem; height: 1rem; background: #fff; transform: translate3d(-1.5rem, 1.2rem, 0) rotate(-70deg); border-radius: 50%; box-shadow: -0.4rem 0 0 #302e9b, -0.4rem 0.4rem 0 0.4rem #fff, -0.1rem 0.4rem 0 0.6rem #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(2):before { width: 0.75rem; height: 0.75rem; background: #fff; transform: translate3d(-11.25rem, -7rem, 0) rotate(-50deg); border-radius: 50%; box-shadow: 0.4rem 0 0 #302e9b, 0.4rem 0.4rem 0 0.3rem #fff, 0.1rem 0.4rem 0 0.6rem #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(4) { width: 3rem; height: 1rem; border-radius: 50%; border-top: 0.4rem solid #302e9b; transform: translate3d(21rem, 1rem, 0); box-shadow: -5rem 0.4rem 0 #fff, -5.5rem 0 0 #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(4):after { width: 0.3rem; height: 2rem; background: #302e9b; transform: translate3d(-2.65rem, 0, 0) rotate(-15deg); } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(4):before { width: 2.5rem; height: 5rem; border-radius: 2rem; transform: translate3d(-2.5rem, 1.25rem, 0) rotate(15deg) skewY(-10deg); box-shadow: -0.2rem 0.3rem 0 #302e9b; background: #fff; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(5) { width: 0.6rem; height: 0.6rem; background: #302e9b; border-radius: 50%; box-shadow: 0 0 0 0.5rem #fff, 0 0 0 0.8rem #302e9b; transform: translate3d(21.5rem, 3rem, 0) rotate(5deg); } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(5):before { width: 3.5rem; height: 3rem; border-radius: 50%; border-top: 0.4rem solid #302e9b; transform: translate3d(-1rem, -0.4rem, 0); box-shadow: 0 -0.8rem 0 -0.4rem #fff; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(5):after { width: 1.5rem; height: 0.75rem; border-radius: 50%; box-shadow: -0.2rem 0.2rem 0 0 #302e9b; transform: translate3d(-0.75rem, 1rem, 0) rotate(20deg); } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(6) { width: 0.6rem; height: 0.6rem; background: #302e9b; border-radius: 50%; box-shadow: 0 0 0 0.5rem #fff, 0 0 0 0.8rem #302e9b; transform: translate3d(16.6rem, 2.75rem, 0) rotate(5deg); } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(6):before { width: 3.5rem; height: 3rem; border-radius: 50%; border-top: 0.4rem solid #302e9b; transform: translate3d(-1rem, -0.4rem, 0); box-shadow: 0 -0.8rem 0 -0.4rem #fff; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(6):after { width: 1rem; height: 0.75rem; border-radius: 50%; box-shadow: 0 0.2rem 0 0 #302e9b; transform: translate3d(-0.75rem, 1rem, 0) rotate(30deg); } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(3) { width: 2rem; height: 1.25rem; background: #fff; border-radius: 50%; box-shadow: 0.3rem 0 0 0 #302e9b; transform: translate3d(18.75rem, 6rem, 0) rotate(45deg); } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(3):before { width: 4rem; height: 4rem; transform: translate3d(0.25rem, 0.25rem, 0); box-shadow: -0.2rem -0.2rem 0 #302e9b; border-radius: 1rem; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(3):after { width: 1rem; height: 1rem; box-shadow: 0 -0.4rem 0 #302e9b; transform: translate3d(3.25rem, 3.25rem, 0) rotate(-45deg); border-radius: 50%; } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(7) { width: 0.6rem; height: 0.6rem; background: #302e9b; border-radius: 50%; box-shadow: 1rem 0 0 0 #302e9b, 0.5rem 0.3rem 0 0 #302e9b; transform: translate3d(18.75rem, 8.5rem, 0); } front > * > *:nth-of-type(2) > *:nth-of-type(7) > *:nth-of-type(7):after { width: 3.2rem; height: 0.5rem; box-shadow: 0 -0.2rem 0 #302e9b; transform: translate3d(-0.7rem, 0.4rem, 0); border-radius: 50%; } front > * > *:nth-of-type(2) > *:nth-of-type(5) { transform: translate3d(36rem, 5rem, 0); border: 0.3rem solid #302e9b; width: 2rem; height: 3.85rem; border-radius: 1rem; background: #fff; box-shadow: 0.75rem 0.3rem 0 -0.3rem #fff, 0.75rem 0.3rem 0 #302e9b, 1.75rem 0.5rem 0 -0.5rem #fff, 1.75rem 0.5rem 0 -0.2rem #302e9b, 2.65rem 0.6rem 0 -0.8rem #fff, 2.65rem 0.6rem 0 -0.4rem #302e9b; } front > * > *:nth-of-type(2) > *:nth-of-type(5):before { transform: translate3d(-1rem, -0.75rem, 0); border: 0.5rem solid #302e.........完整代码请登录后点击上方下载按钮下载查看
网友评论1