div+css实现6个不同食物飞盘点击开关切换效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现6个不同食物飞盘点击开关切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { display: flex; width: 100vw; height: 100vh; background: #f5f4e2; justify-content: center; align-items: center; } body .wrap { width: 580px; height: 460px; } body .wrap .toggle { display: inline-block; float: left; background: #fff; width: 250px; height: 100px; box-shadow: 0 5px 25px -15px #676550; position: relative; margin: 50px 20px 0px; border-radius: 100px; opacity: 0; -webkit-animation: fadein 1.5s ease-in 1 forwards; animation: fadein 1.5s ease-in 1 forwards; } body .wrap .toggle:before { position: absolute; color: #e1dea9; font-family: "Nunito"; letter-spacing: 3px; width: 100%; text-align: center; top: -25px; font-size: 20px; } body .wrap .toggle .toppings { transform: scale(0) rotate(0deg); transition: 0.15s ease-in-out; } body .wrap .toggle .toppings:nth-of-type(1) { left: 18px; top: 14px; margin-top: 10.5px; margin-left: 5px; } body .wrap .toggle .toppings:nth-of-type(2) { left: 36px; top: 28px; margin-top: 10.5px; margin-left: 5px; } body .wrap .toggle .toppings:nth-of-type(3) { left: 54px; top: 42px; margin-top: 10.5px; margin-left: 5px; } body .wrap .toggle .toppings:nth-of-type(4) { left: 72px; top: 56px; margin-top: 10.5px; margin-left: 5px; } body .wrap .toggle .toppings:nth-of-type(5) { left: 90px; top: 70px; margin-top: 10.5px; margin-left: 5px; } body .wrap .toggle .toppings:nth-of-type(4) { left: 55px; top: 28px; margin-top: 0; margin-left: 0; } body .wrap .toggle .toppings:nth-of-type(5) { left: 25px; top: 58px; margin-top: 0; margin-left: 0; } body .wrap .toggle:nth-of-type(1) { -webkit-animation-delay: 0.1s; animation-delay: 0.1s; } body .wrap .toggle:nth-of-type(2) { -webkit-animation-delay: 0.2s; animation-delay: 0.2s; } body .wrap .toggle:nth-of-type(3) { -webkit-animation-delay: 0.3s; animation-delay: 0.3s; } body .wrap .toggle:nth-of-type(4) { -webkit-animation-delay: 0.4s; animation-delay: 0.4s; } body .wrap .toggle:nth-of-type(5) { -webkit-animation-delay: 0.5s; animation-delay: 0.5s; } body .wrap .toggle:nth-of-type(6) { -webkit-animation-delay: 0.6s; animation-delay: 0.6s; } body .wrap .toggle:nth-of-type(1):before { content: "PEPPERONI"; } body .wrap .toggle:nth-of-type(1) .toppings { position: absolute; width: 10px; height: 10px; border-radius: 100%; background: #DC453F; position: absolute; } body .wrap .toggle:nth-of-type(2):before { content: "SAUSAGE"; } body .wrap .toggle:nth-of-type(2) .toppings { position: absolute; width: 10px; height: 5px; background: #b0926d; position: absolute; border-radius: 5px 5px 0 0; } body .wrap .toggle:nth-of-type(2) .toppings:before { content: ""; position: absolute; width: 50%; height: 75%; border-radius: 15px 15px 0 0; background: #b0926d; bottom: 0; left: -2.5px; } body .wrap .toggle:nth-of-type(3):before { content: "PINEAPPLE"; } body .wrap .toggle:nth-of-type(3) .toppings { position: absolute; width: 5px; height: 5px; background: #ffffa2; position: absolute; } body .wrap .toggle:nth-of-type(3) .toppings:before { content: ""; position: absolute; width: 50%; height: 75%; border-radius: 0; background: #ffff3c; bottom: 0; left: -2.5px; } body .wrap .toggle:nth-of-type(3):before { content: "PINEAPPLE"; } body .wrap .toggle:nth-of-type(3) .toppings { position: absolute; width: 5px; height: 5px; background: #ffffa2; position: absolute; } body .wrap .toggle:nth-of-type(3) .toppings:before { content: ""; position: absolute; width: 50%; height: 75%; border-radius: 0; background: #ffff3c; bottom: 0; left: -2.5px; } body .wrap .toggle:nth-of-type(4):before { content: "PEPPERS"; } body .wrap .toggle:nth-of-type(4) .toppings { position: absolute; width: 10px; height: 10px; background: #FFD72C; position: absolute; border-radius: 100%; box-shadow: inset 3px 0 0 #4cad7b; } body .wrap .toggle:nth-of-type(4) .toppings:before { content: ""; position: absolute; width: 7px; height: 7px; top: -5px; background: #FFD72C; position: absolute; border-radius: 100%; box-shadow: inset 3px 0 0 #4cad7b; } body .wrap .toggle:nth-of-type(5):before { content: "NY STYLE"; } body .wrap .toggle:nth-of-type(5) input:checked ~ .pizza { -webkit-animation: pizzaflip2 0.75s linear 1 forwards; animation: pizzaflip2 0.75s linear 1 forwards; } @-webkit-keyframes pizzaflip2 { 0% { transform: translateX(0) scale(1); } 25% { transform: translateX(75px) translateY(-15px) scale(1.5); } 75% { transform: translateX(100px) translateY(-15px) scale(1.5); } 100% { transform: translateX(150px) scale(1.35) rotateX(-20deg); } } @keyframes pizzaflip2 { 0% { transform: translateX(0) scale(1); } 25% { transform: translateX(75px) translateY(-15px) scale(1.5); } 75% { transform: translateX(100px) translateY(-15px) scale(1.5); } 100% { transform: translateX(150px) scale(1.35) rotateX(-20deg); } } body .wrap .toggle:nth-of-type(6):before { content: "CHICAGO STYLE"; } body .wrap .toggle:nth-of-type(6) input:checked ~ .pizza .inner { -webkit-animation: spinwobble2 0.9s linear 1 forwards; animation: spinwobble2 0.9s linear 1 forwards; } @-webkit-keyframes spinwobble2 { 0% { transform: rotateX(0deg) rotate(0deg); } 40% { transform: rotateX(-30deg) rotate(180deg); } 60% { transform: rotateX(-30deg) rotate(360deg); } 80% { transform: rotateX(30deg) rotate(360deg); box-shadow: inset 0 0 0 10px #FFB10B, inset 0 0 0px 0px #FFD72C, 0 0px 0px #d79200, 0 0px #ca8a00; background: linear-gradient(45deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), linear-gradient(-45deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), linear-gradient(90deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), linear-gradient(180deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), #FFD72C; } 100% { transform: rotateX(0deg) rotate(360deg) translateY(-20px); box-shadow: inset 0 0 0 10px #FFB10B, inset 0 0 5px 13px #FFD72C, 0 10px 5px #d79200, 0 15px #ca8a00; background: linear-gradient(45deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), linear-gradient(-45deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), linear-gradient(90deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), linear-gradient(180deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), #DC453F; } } @keyframes spinwobble2 { 0% { transform: rotateX(0deg) rotate(0deg); } 40% { transform: rotateX(-30deg) rotate(180deg); } 60% { transform: rotateX(-30deg) rotate(360deg); } 80% { transform: rotateX(30deg) rotate(360deg); box-shadow: inset 0 0 0 10px #FFB10B, inset 0 0 0px 0px #FFD72C, 0 0px 0px #d79200, 0 0px #ca8a00; background: linear-gradient(45deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), linear-gradient(-45deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), linear-gradient(90deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), linear-gradient(180deg, transparent, transparent 49%, #f8c900 49%, #f8c900 51%, transparent 51%), #FFD72C; } 100% { transform: rotateX(0deg) rotate(360deg) translateY(-20px); box-shadow: inset 0 0 0 10px #FFB10B, inset 0 0 5px 13px #FFD72C, 0 10px 5px #d79200, 0 15px #ca8a00; background: linear-gradient(45deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), linear-gradient(-45deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), linear-gradient(90deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), linear-gradient(180deg, transparent, transparent 49%, #c42a24 49%, #c42a24 51%, transparent 51%), #DC453F; } } @-webkit-keyframes fadein { 0% { opacity: 0; } 75% { opacity: 0; transform: scale(0); } 100% { opacity: 1; transform: scale(1); } } @keyframes fadein { 0% { opacity: 0; } 75% { opacity: 0; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0