css实现一个老式带声音三维收音机闹钟起床器效果代码
代码语言:html
所属分类:三维
代码描述:css实现一个老式带声音三维收音机闹钟起床器效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @charset "UTF-8"; /*** DEBUGGING SOME ERROR IN FIREFOX ***/ @import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Michroma&display=swap"); :root { --bf: #111; --grad: linear-gradient(0deg, #ffffffab, #ffffffdb); --deca: polygon( 34.54915% 2.44717%, 65.45085% 2.44717%, 90.45085% 20.61074%, 100% 50%, 90.45085% 79.38926%, 65.45085% 97.55283%, 34.54915% 97.55283%, 9.54915% 79.38926%, 0% 50%, 9.54915% 20.61074% ); } * { transform-style: preserve-3d; box-sizing: border-box; } body { margin: 0; height: 100vh; overflow: hidden; background: radial-gradient(circle at 50% 50%, #333, #000); font-family: Arial, Helvetica, serif; } .cam { transform: translateZ(30vmin); float: left; width: 11.11%; height: 11.11%; z-index: 1; position: relative; cursor: pointer; } .cam:nth-child(1):hover ~ .content .clock { transform: rotateX(40deg) rotateY(-40deg); } .cam:nth-child(2):hover ~ .content .clock { transform: rotateX(40deg) rotateY(-30deg); } .cam:nth-child(3):hover ~ .content .clock { transform: rotateX(40deg) rotateY(-20deg); } .cam:nth-child(4):hover ~ .content .clock { transform: rotateX(40deg) rotateY(-10deg); } .cam:nth-child(5):hover ~ .content .clock { transform: rotateX(40deg) rotateY(0deg); } .cam:nth-child(6):hover ~ .content .clock { transform: rotateX(40deg) rotateY(10deg); } .cam:nth-child(7):hover ~ .content .clock { transform: rotateX(40deg) rotateY(20deg); } .cam:nth-child(8):hover ~ .content .clock { transform: rotateX(40deg) rotateY(30deg); } .cam:nth-child(9):hover ~ .content .clock { transform: rotateX(40deg) rotateY(40deg); } .cam:nth-child(10):hover ~ .content .clock { transform: rotateX(30deg) rotateY(-40deg); } .cam:nth-child(11):hover ~ .content .clock { transform: rotateX(30deg) rotateY(-30deg); } .cam:nth-child(12):hover ~ .content .clock { transform: rotateX(30deg) rotateY(-20deg); } .cam:nth-child(13):hover ~ .content .clock { transform: rotateX(30deg) rotateY(-10deg); } .cam:nth-child(14):hover ~ .content .clock { transform: rotateX(30deg) rotateY(0deg); } .cam:nth-child(15):hover ~ .content .clock { transform: rotateX(30deg) rotateY(10deg); } .cam:nth-child(16):hover ~ .content .clock { transform: rotateX(30deg) rotateY(20deg); } .cam:nth-child(17):hover ~ .content .clock { transform: rotateX(30deg) rotateY(30deg); } .cam:nth-child(18):hover ~ .content .clock { transform: rotateX(30deg) rotateY(40deg); } .cam:nth-child(19):hover ~ .content .clock { transform: rotateX(20deg) rotateY(-40deg); } .cam:nth-child(20):hover ~ .content .clock { transform: rotateX(20deg) rotateY(-30deg); } .cam:nth-child(21):hover ~ .content .clock { transform: rotateX(20deg) rotateY(-20deg); } .cam:nth-child(22):hover ~ .content .clock { transform: rotateX(20deg) rotateY(-10deg); } .cam:nth-child(23):hover ~ .content .clock { transform: rotateX(20deg) rotateY(0deg); } .cam:nth-child(24):hover ~ .content .clock { transform: rotateX(20deg) rotateY(10deg); } .cam:nth-child(25):hover ~ .content .clock { transform: rotateX(20deg) rotateY(20deg); } .cam:nth-child(26):hover ~ .content .clock { transform: rotateX(20deg) rotateY(30deg); } .cam:nth-child(27):hover ~ .content .clock { transform: rotateX(20deg) rotateY(40deg); } .cam:nth-child(28):hover ~ .content .clock { transform: rotateX(10deg) rotateY(-40deg); } .cam:nth-child(29):hover ~ .content .clock { transform: rotateX(10deg) rotateY(-30deg); } .cam:nth-child(30):hover ~ .content .clock { transform: rotateX(10deg) rotateY(-20deg); } .cam:nth-child(31):hover ~ .content .clock { transform: rotateX(10deg) rotateY(-10deg); } .cam:nth-child(32):hover ~ .content .clock { transform: rotateX(10deg) rotateY(0deg); } .cam:nth-child(33):hover ~ .content .clock { transform: rotateX(10deg) rotateY(10deg); } .cam:nth-child(34):hover ~ .content .clock { transform: rotateX(10deg) rotateY(20deg); } .cam:nth-child(35):hover ~ .content .clock { transform: rotateX(10deg) rotateY(30deg); } .cam:nth-child(36):hover ~ .content .clock { transform: rotateX(10deg) rotateY(40deg); } .cam:nth-child(37):hover ~ .content .clock { transform: rotateX(0deg) rotateY(-40deg); } .cam:nth-child(38):hover ~ .content .clock { transform: rotateX(0deg) rotateY(-30deg); } .cam:nth-child(39):hover ~ .content .clock { transform: rotateX(0deg) rotateY(-20deg); } .cam:nth-child(40):hover ~ .content .clock { transform: rotateX(0deg) rotateY(-10deg); } .cam:nth-child(41):hover ~ .content .clock { transform: rotateX(0deg) rotateY(0deg); } .cam:nth-child(42):hover ~ .content .clock { transform: rotateX(0deg) rotateY(10deg); } .cam:nth-child(43):hover ~ .content .clock { transform: rotateX(0deg) rotateY(20deg); } .cam:nth-child(44):hover ~ .content .clock { transform: rotateX(0deg) rotateY(30deg); } .cam:nth-child(45):hover ~ .content .clock { transform: rotateX(0deg) rotateY(40deg); } .cam:nth-child(46):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(-40deg); } .cam:nth-child(47):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(-30deg); } .cam:nth-child(48):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(-20deg); } .cam:nth-child(49):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(-10deg); } .cam:nth-child(50):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(0deg); } .cam:nth-child(51):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(10deg); } .cam:nth-child(52):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(20deg); } .cam:nth-child(53):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(30deg); } .cam:nth-child(54):hover ~ .content .clock { transform: rotateX(-10deg) rotateY(40deg); } .cam:nth-child(55):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(-40deg); } .cam:nth-child(56):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(-30deg); } .cam:nth-child(57):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(-20deg); } .cam:nth-child(58):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(-10deg); } .cam:nth-child(59):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(0deg); } .cam:nth-child(60):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(10deg); } .cam:nth-child(61):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(20deg); } .cam:nth-child(62):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(30deg); } .cam:nth-child(63):hover ~ .content .clock { transform: rotateX(-20deg) rotateY(40deg); } .cam:nth-child(64):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(-40deg); } .cam:nth-child(65):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(-30deg); } .cam:nth-child(66):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(-20deg); } .cam:nth-child(67):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(-10deg); } .cam:nth-child(68):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(0deg); } .cam:nth-child(69):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(10deg); } .cam:nth-child(70):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(20deg); } .cam:nth-child(71):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(30deg); } .cam:nth-child(72):hover ~ .content .clock { transform: rotateX(-30deg) rotateY(40deg); } .cam:nth-child(73):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(-40deg); } .cam:nth-child(74):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(-30deg); } .cam:nth-child(75):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(-20deg); } .cam:nth-child(76):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(-10deg); } .cam:nth-child(77):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(0deg); } .cam:nth-child(78):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(10deg); } .cam:nth-child(79):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(20deg); } .cam:nth-child(80):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(30deg); } .cam:nth-child(81):hover ~ .content .clock { transform: rotateX(-40deg) rotateY(40deg); } .cam:active ~ .content { transform: scale3d(1.5, 1.5, 1.5); transition: all 1s ease 0.5s; } .cam:hover ~ .content { transition: all 1s ease 0.5s; } body.zoom .cam { cursor: zoom-in; } .content { width: 100vw; height: 100vh; margin: 0 auto; justify-content: center; align-items: center; display: flex; flex-wrap: wrap; align-content: center; perspective: 150vmin; perspective-origin: center; position: absolute; z-index: -1; transition: all 1s ease 0.5s; } /*** CUBOID ***/ .cuboid { --hue: 0; --sat: 0%; height: calc(var(--height) * 1vmin); width: calc(var(--width) * 1vmin); position: absolute; } .side { position: absolute; top: 50%; left: 50%; height: 100%; width: 100%; box-sizing: border-box; border-radius: 0.35vmin; } .side:nth-of-type(1) { transform: translate3d(-50%, -50%, calc(var(--depth) * 0.5vmin)); background: var(--grad), hsl(var(--hue), var(--sat), 50%); } .side:nth-of-type(2) { transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin)) rotateY(180deg); background: var(--grad), hsl(var(--hue), var(--sat), 35%); } .side:nth-of-type(3) { width: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateY(90deg) translate3d(0, 0, calc(var(--width) * 0.5vmin)); background: var(--grad), hsl(var(--hue), var(--sat), 40%); } .side:nth-of-type(4) { width: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateY(-90deg) translate3d(0, 0, calc(var(--width) * 0.5vmin)); background: var(--grad), hsl(var(--hue), var(--sat), 60%); } .side:nth-of-type(5) { height: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateX(90deg) translate3d(0, 0, calc(var(--height) * 0.5vmin)); background: var(--grad), hsl(var(--hue), var(--sat), 70%); border: 1px solid hsl(var(--hue), 0%, 50%); } .side:nth-of-type(6) { height: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateX(-90deg) translate3d(0, 0, calc(var(--height) * 0.5vmin)); background: var(--grad), hsl(var(--hue), var(--sat), 25%); } /*** CLOCK ***/ .clock { --width: 80; --height: 20; --depth: 60; transform: rotateX(-10deg) rotateY(20deg); transition: all 0.5s ease 0s; animation: init 3.8s ease 0s; } .clock > .side:nth-child(1) { background: linear-gradient(-40deg, #fff0 0 44%, #122f4630 45.35% 52%, #fff0 55.35% 57%, #122f4661 60.25% 65%, #fff0 75.25% 100%), #051c2e3b; } .clock > .side:nth-of-type(5) { font-size: 1.35vmin; text-shadow: 0 -1px 0 #ccc; color: #fff; } .clock > .side:nth-of-type(5):before { content: ""; position: absolute; background: repeating-radial-gradient(#f7f7f7bd 0 30%, #fff0 35% 100%); width: 55%; height: 58%; left: 24%; top: 10%; background-repeat: repeat; background-size: 1.25vmin 1.25vmin; filter: drop-shadow(-1px 1px 1px #000); } .clock > .side:nth-of-type(5):after { position: absolute; width: 11%; height: 7%; left: 82%; top: 82%; border: 0.1vmin solid #fff0; border-color: #00000014 #fff9 #fff9 #00000014; border-radius: 0.5vmin; font-size: 1vmin; content: "FM AM"; word-spacing: 4vmin; text-align: center; padding: 1.35vmin 0.5vmin; box-sizing: border-box; background: radial-gradient(circle at 45% 50%, #3a3a3a 0 1.25vmin, transparent 1.35vmin 100%), radial-gradient(circle at 50% 50%, #3a3a3a 0 1.25vmin, transparent 1.35vmin 100%), radial-gradient(circle at 55% 50%, #3a3a3a 0 1.25vmin, transparent 1.35vmin 100%); } @keyframes init { 50% { transform: rotateX(10deg) rotateY(-20deg); } } .sleep { position: absolute; bottom: 11vmin; left: 2vmin; } .sleep:before { content: " 0FF \aON"; white-space: pre-wrap; position: absolute; top: -3.75vmin; line-height: 1vmin; font-size: 1.25vmin; left: 7vmin; } .sleep:after { content: " ALARM \a AUTO"; white-space: pre-wrap; position: absolute; top: -8.75vmin; line-height: 2vmin; font-size: 1.125vmin; left: 11.5vmin; } /*** BASE ***/ .base { --width: 60; --height: 8; --depth: 40; transform: translate3d(10vmin, 20vmin, 0vmin); } .base > .side { border: 0.125vmin solid #0003; } /*** BLACK ***/ .black { --width: 79; --height: 19; --depth: 55; transform: translate3d(0.5vmin, 0.5vmin, -2vmin); } .black > .side { border: 0.125vmin solid #0004; background: #333; } .black > .side:nth-of-type(1) { background: linear-gradient(90deg, var(--bf) 0 6%, #fff0 0 13%, var(--bf) 0 19%, #fff0 0 49%, var(--bf) 0 54%, #fff0 0 95%, var(--bf) 0 100%), linear-gradient(0deg, var(--bf) 0 18%, #fff0 0 82%, var(--bf) 0 100%); } /*** DIAL ***/ .dial { --width: 32; --height: 12; --depth: 55; transform: translate3d(43.5vmin, 4.075vmin, -2vmin); } .dial > .side { border: 0.125vmin solid #0004; background: #111; } .dial > .side:nth-of-type(1) { transform: translate3d(-50%, -50%, calc(var(--depth) * 0.485vmin)); background: #000; } .dial > .side:nth-of-type(1):before { content: "Panasonic"; color: #fff; font-weight: bold; font-size: 1.85vmin; float: left; width: 100%; text-align: right; padding: 1vmin 1.5vmin 1vmin 1vmin; box-sizing: border-box; } .dial > .side:nth-of-type(1):after { content: ""; font-weight: bold; float: left; width: calc(100% - 2vmin); border-bottom: 0.5vmin dotted #fff; margin: 2vmin 1vmin 1vmin; } .dial > .side:nth-of-type(1) > div { color: #fff; font-size: 1.5vmin; } .am { word-spacing: 0.4vmin; margin-top: 1.25vmin; } .am:before { content: "AM"; float: left; margin-right: 4vmin; margin-left: 1vmin; } .fm { word-spacing: 0.35vmin; } .fm:before { content: "FM"; float: left; margin-right: 4vmin; margin-left: 1vmin; } .needle { background: #b30000; width: 0.2vmin; height: 9vmin; position: absolute; bottom: -0.5vmin; left: 12.35vmin; border: 1px solid #0002; box-shadow: 0.125vmin -0.125vmin 1vmin 0 #0006; border-bottom: 0; border-radius: 0.15vmin 0.15vmin 0 0; } /*** MINUTES ***/ .minutes { --width: 11; --height: 12; --depth: 10; transform: translate3d(27.5vmin, 4.075vmin, 19.5vmin); } .minutes > .side { border: 0.125vmin solid #0004; background: #1c1c1cb8; } .minutes > .side:nth-of-type(4):before, .minutes > .side:nth-of-type(3):before, .minutes > .side:nth-of-type(4):before { content: ""; background: repeating-linear-gradient(0deg, #111 0 1.5%, #222 0 2.75%); width: 1vmin; height: 100%; position: absolute; right: 0; transform-origin: right center; transform: rotateY(90deg); } .minutes > .side:nth-of-type(3):before { left: 0; transform-origin: left center; transform: rotateY(-90deg); border-right: 0.5vmin solid #2a2a2a; width: 0.5vmin; } .num { height: 46%; background: #000000; border: 1px solid #333; border-radius: 0.5vmin 0.5vmin 0 0; font-family: "Bebas Neue", Arial, Helvetica, serif; color: #fff; font-size: 11vmin; text-align: center; width: 94%; margin-left: 2%; line-height: 12vmin; } .num.top { margin-top: 2%; } .num.top.move { transform-origin: center bottom; transform: rotateX(0deg); animation: wakeup 0.35s ease-in 0s 1; animation-play-state: paused; animation-fill-mode: forwards; } .num.top.fixed { position: absolute; top: 0; z-index: -1; } .num.top.fixed:before { content: ""; background: #101010; width: 100%; height: 0.1vmin; position: absolute; bottom: 0; left: 0; } .num.bot { border-radius: 0 0 0.5vmin 0.5vmin; line-height: 0vmin; overflow: hidden; } .clock.active .num.top.move { animation-play-state: running; } @keyframes wakeup { 100% { transform: rotateX(-175deg); } } /*** HOURS ***/ .hours { --width: 10; --height: 12; --depth: 10; transform: translate3d(16.5vmin, 4.075vmin, 19.5vmin); } .hours > .side { border: 0.125vmin solid #0004; background: #1c1c1cb8; } .hours > .side:nth-of-type(4):before { width: 0.75vmin; border-left: 0.5vmin solid #2a2a2a; } .hours .num.top.move { animation-delay: 0.1s; animation-duration: 0.25s; } /*** WHEEL ***/ .wheel { --width: 5.5; --height: 12; --depth: 10; transform: translate3d(5.25vmin, 4.075vmin, 20.5vmin); } .wheel > .side { border: 0.125vmin solid #0004; background: #1c1c1c; } .wheel > .side:nth-of-type(1) { opacity: 0; } .wheel > .side:nth-of-type(3):before { content: ""; position: absolute; border: 0.2vmin solid #fff0; border-left: 1.5vmin solid #b30000; top: calc(50% - 0.35vmin); transform: rotateY(90deg); transform-origin: left center; } /*** NUMBERS ***/ .numbers { --width: 24; --height: 12; --depth: 12; transform: translate3d(15.5vmin, 4.075vmin, 19.5vmin); } .numbers > .side { border: 0.125vmin solid #0004; background: #000; } .numbers > .side:nth-child(1) { opacity: 0; } .numbers > .side:nth-of-type(6):before { content: ""; width: 24vmin; height: 12vmin; position: absolute; left: 0; box-shadow: 0 -2vmin 2vmin 0 #ffcc0036 inset, 0 2vmin 2vmin 0 #ffcc0036 inset; transform: rotateX(-90deg) translateY(6vmin) translateZ(-6vmin); background: radial-gradient(circle at 24% 103%, #ffcc0080 0 0%, #fff0 30% 100%), radial-gradient(circle at 70% 103%, #ffcc0080 0 0%, #fff0 30% 100%); opacity: 0.5; } .front, .back { backface-visibility: hidden; box-sizing: border-box; color: white; display: block; height: 100%; position: absolute; text-align: center; width: 100%; } .back { transform: rotateY(180deg); } /*** DECAGON ***/ .decagon { --width: 19; --height: 19; --depth: 5; --hue: 200; --sat: 0%; height: calc(var(--height) * 1vmin); width: calc(var(--width) * 1vmin); position: absolute; transform: translate3d(-1.5vmin, 0.5vmin, 16vmin) rotateZ(45deg) rotateX(90deg) rotateY(45deg) rotate(145deg); } .decagon .face { --line: conic-gradient(from 180deg at 6% 0%, #fff 0 25%, #fff0 0 100%); position: absolute; top: 50%; left: 50%; height: 100%; width: 100%; background: var(--line), var(--line), var(--line), var(--line), var(--line), var(--line), var(--line), var(--line), var(--line), linear-gradient(0deg, #fff 0 20%, #111 0 100%); overflow: hidden; background-size: 38% 56%, 38% 56%, 38% 56%, 38% 56%, 38% 56%, 38% 56%, 38% 56%, 38% 56%, 38% 56%, 100% 100%; background-repeat: no-repeat; background-position: 16% 160%, 151% 160%, 68% 160%, 50% 160%, 103% 160%, 118% 160%, 135% 130%, 85% 130%, 31% 130%, 0 0; } .decagon .face:nth-of-type(1) { clip-path: var(--deca); transform: translate3d(-50%, -50%, calc(var(--depth) * 0.5vmin)); background: #222; box-shadow: none; border: 0; background-size: 0.5% 0.5%; } .decagon .face:nth-of-type(2) { clip-path: var(--deca); transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin)) rotateY(180deg); background: #222; box-shadow: none; border: 0; background-size: 0.5% 0.5%; } .decagon .face:nth-of-type(1n + 3) { width: calc(calc(calc(var(--width) * 31) / 100) * 1vmin); height: calc(var(--depth) * 1vmin); transform: translate(-50%, -50%) rotateY(90deg) rotateX(90deg) rotateZ(-90deg) translate3d(0vmin, 0, calc(var(--width) * 0.475vmin)); filter: hue-rotate(360deg); display: flex; justify-content: center; } .decagon .face:nth-of-type(1n + 3):after { content: ""; transform: rotate(-90deg); font-family: "Michroma", Arial, Helvetica, serif; position: absolute; font-size: 1vmin; color: #fff; text-align: right; max-width: 2.1vmin; line-height: 1.85vmin; top: -0.25vmin; } .decagon .face:nth-of-type(3):after { content: "4 3 2"; } .decagon .face:nth-of-type(4) { transform: translate(-50%, -50%) rotateY(90deg) rotateX(54deg) rotateZ(-90deg) translate3d(0vmin, 0, calc(var(--width) * 0.475vmin)); } .decagon .face:nth-of-type(4):after { content: "7 6 5"; } .decagon .face:nth-of-type(5) { transform: translate(-50%, -50%) rotateY(90deg) rotateX(18deg) rotateZ(-90deg) translate3d(0vmin, 0, calc(var(--width) * 0.475vmin)); } .decagon .face:nth-of-type(5):after { content: "10 9 8"; } .decagon .face:nth-of-type(6) { transform: translate(-50%, -50%) rotateY(90deg) rotateX(-18deg) rotateZ(-90deg) translate3d(0vmin, 0, calc(var(--width) * 0.475vmin)); } .decagon .face:nth-of-type(7) { transform: translate(-50%, -50%) rotateY(90deg) rotateX(-54deg) rotateZ(-90deg) translate3d(0vmin, 0, calc(var(--width) * 0.475vmin)); } .decagon .face:nth-of-type(8) { transform: translate(-50%, -50%) rotateY(90deg) rotateX(-90deg) rotateZ(-90deg.........完整代码请登录后点击上方下载按钮下载查看
网友评论0