纯css实现任天堂游戏机布局效果
代码语言:html
所属分类:布局界面
代码描述:纯css实现任天堂游戏机布局效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <style> :root { --red: #FA4233; --blue: #00ABD1; --scene-bg: hotpink; --switch-width: 77.12vw; --switch-height: 32.48vw; --switch-body-width: 55.52vw; --screen-bg: #030303; --screen-body-bg: #2C2E2F; --screen-inner-bg: #1E1E1E; --screen-reflect-color: rgba(255, 255, 255, 0.1); --screen-width: 52.8vw; --screen-height: 29.84vw; --screen-inner-width: 44.64vw; --screen-inner-height: 24.4vw; --joycon-width: 10.72vw; --joycon-button-bg: #323639; } *, *::before, *::after { box-sizing: border-box; } body { margin: 0; font-family: sans-serif; } .scene { width: 100vw; height: 100vh; background-color: var(--scene-bg); display: -webkit-box; display: flex; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; } .switch { position: relative; width: var(--switch-width); height: var(--switch-height); } .screen { width: var(--screen-width); height: var(--screen-height); border-radius: 0.48vw; background-color: var(--screen-bg); display: -webkit-box; display: flex; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; } .screen-body { width: var(--switch-body-width); height: 100%; position: absolute; bottom: 0; left: var(--joycon-width); border-radius: 0.32vw; background-color: var(--screen-body-bg); display: -webkit-box; display: flex; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; } .screen-body::before, .screen-body::after { content: ""; width: 0.8vw; height: 1.28vw; position: absolute; top: 0; z-index: 1; background-color: var(--scene-bg); } .screen-body::before { left: 0; border-bottom-right-radius: 0.32vw; } .screen-body::after { right: 0; border-bottom-left-radius: 0.32vw; } .screen-inner { width: var(--screen-inner-width); height: var(--screen-inner-height); background-color: var(--screen-inner-bg); background-image: linear-gradient(-45deg, transparent 0%, transparent 10%, var(--screen-reflect-color) 10%, var(--screen-reflect-color) 20%, transparent 20%, transparent 30%, var(--screen-reflect-color) 30%, var(--screen-reflect-color) 40%, transparent 40%, transparent 50%, var(--screen-reflect-color) 50%, var(--screen-reflect-color) 60%, transparent 60%, transparent 70%, var(--screen-reflect-color) 70%, var(--screen-reflect-color) 80%, transparent 80%, transparent 90%, var(--screen-reflect-color) 90%); } .joycon { width: var(--joycon-width); height: 100%; position: absolute; top: 0; z-index: 1; } .joycon.is-red { background-color: var(--red); } .joycon.is-blue { background-color: var(--blue); } .joycon.is-left { left: 0; border-radius: 5.76vw 0.32vw 0.32vw 5.76vw; } .joycon.is-right { left: calc(var(--joycon-width) + var(--switch-body-width)); border-radius: 0.32vw 5.76vw 5.76vw 0.32vw; } .joycon-button-group { width: 6.8vw; height: 6.8vw; position: absolute; } .joycon-button-group.arrows { bottom: 11.36vw; right: 1.2vw; } .joycon-button-group.letters { top: 4.32vw; left: 1.2vw; } .joycon-button { position: absolute; font-size: 1.12vw; line-height: 1; color: #D7DBE1; display: -webkit-box; display: flex; -webkit-box-pack: center; justify-content: center; -webkit-box-align: center; align-items: center; width: 2.4vw; height: 2.4vw; border-radius: 50%; background-color: var(--joycon-button-bg); -webkit-perspective: 500px; perspective: 500px; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; } .joycon-button::after { content: ""; position: absolute; z-index: -1; -webkit-transform: scale(1.1) translateZ(-0.08vw); transform: scale(1.1) translateZ(-0.08vw); width: 100%; height: 100%; border-radius: 50%; background-color: rgba(0, 0, 0, 0.3); } .joycon-button.up::before { content: ""; width: 0; height: 0; border-style: solid; border-width: 0 4px 6px 4px; border-color: transparent transparent #1b1b1b transparent; } .joycon-button.down::before { content: ""; width: 0; height: 0; border-style: solid; border-width: 6px 4px 0 4px; border-color: #1b1b1b transparent transparent transparent; } .joycon-button.left::before { content: ""; width: 0; height: 0; border-style: solid; border-width: 4px 6px 4px 0; border-color: transparent #1b1b1b transparent transparent; } .joycon-button.right::before { content: ""; width: 0; height: 0; border-style: solid; border-width: 4px 0 4px 6px; border-color: transparent transparent transparent #1b1b1b; } .joycon-button.x, .joycon-button.up { top: 0; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); } .joycon-button.y, .joycon-button.left { top: 50%; left: 0; -webkit-transform: translateY(-50%); transform: translateY(-50%); } .joycon-button.a, .joycon-button.right { top: 50%; right: 0; -webkit-transform: translateY(-50%); transform: translateY(-50%); } .joycon-button.b, .joycon-button.down { bottom: 0; left: 50%; -webkit-transform: translateX(-50%); transform: translateX(-50%); } .joycon-analog { --bg: #2F3335; --border-size: 0.56vw; --shadow-color: rgba(0, 0, 0, 0.3); position: absolute; width: 4.48vw; height: 4.48vw; border-radius: 50%; background-color: var(--bg); -webkit-perspective: 500px; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0