div+css实现立方体到六边形步骤动画效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现立方体到六边形步骤动画效果代码,点击按钮一步一步变形成六边形。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css?family=Raleway:400,400i,700"); *, *::before, *::after { padding: 0; margin: 0 auto; box-sizing: border-box; } body { font-family: Raleway, sans-serif; background-color: #000; color: #fff; min-height: 100vh; perspective: 800px; overflow: hidden; *:not(:empty) { transform-style: preserve-3d; } } input[type="radio"] { display: none; &#init:checked { ~ .text::after { content: "Today I learned that..." } ~ .labels label[for="stage0"] { opacity: 1; pointer-events: revert; } ~ .cube { transform: rotateX(-30deg) rotateY(-120deg); i { -webkit-animation: none; animation: none; } } } &#stage0:checked { ~ .text::after { content: "If we draw a diagonal line across a side of a cube, from the center of one edge to the next..." } ~ .labels label[for="stage1"] { opacity: 1; pointer-events: revert; } ~ .cube { transform: rotateX(-45deg) rotateY(-45deg); i:nth-child(1) { -webkit-animation-play-state: running, paused; animation-play-state: running, paused; } } } &#stage1:checked { ~ .text::after { content: "And continue the line on to the next side..." } ~ .labels label[for="stage2"] { opacity: 1; pointer-events: revert; } ~ .cube { transform: rotateX(30deg) rotateY(-180deg); i:nth-child(-n + 2) { -webkit-animation-play-state: running, paused; animation-play-state: running, paused; } } } &#stage2:checked { ~ .text::after { content: "And the next..." } ~ .labels label[for="stage3"] { opacity: 1; pointer-events: revert; } ~ .cube { transform: rotateX(30deg) rotateY(-75deg); i:nth-child(-n + 3) { -webkit-animation-play-state: running, paused; animation-play-state: running, paused; } } } &#stage3:checked { ~ .text::after { content: "And continue doing it..." } ~ .labels label[for="stage4"] { opacity: 1; pointer-events: revert; } ~ .cube { transform: rotateX(75deg) rotateY(-75deg); i:nth-child(-n + 4) { -webkit-animation-play-state: running, paused; animation-play-state: running, paused; } } } &#stage4:checked { ~ .text::after { content: "All around the cube..." } ~ .labels label[for="stage5"] { opacity: 1; pointer-events: revert; } ~ .cube { transform: rotateX(0deg) rotateY(0deg); i:nth-child(-n + 5) { -webkit-animation-play-state: running, paused; animation-play-state: running, paused; } } } &#stage5:checked { ~ .text::after { content: "We'll end up with..." } ~ .labels label[for="stage6"] { opacity: 1; pointer-events: revert; } ~ .cube { transform: rotateX(-10deg) rotateY(75deg); i:nth-child(-n + 6) { -webkit-animation-play-state: running, paused; animation-play-state: running, paused; } } } &#stage6:checked { ~ .text::after { content: "A perfect Hexagon!" } ~ .labels label[for="init"] { opacity: 0.5; pointer-events: revert; transition-delay: 2s; } ~ .cube { transform: rotateX(-45deg) rotateY(-45deg); i { -webkit-animation-play-state: running; animation-play-state: running; } } } } .text { position: absolute; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0