纯css实现三原色调色板效果代码
代码语言:html
所属分类:图表
代码描述:纯css实现三原色调色板效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --clr-red: #ff0000; --clr-darkorange: #ff8000; --clr-yellow: #ffff00; --clr-chartreuse: #80ff00; --clr-green: #00ff00; --clr-springgreen: #00ff80; --clr-cyan: #00ffff; --clr-dodgerblue: #0080ff; --clr-blue: #0000ff; --clr-electricindigo: #8000ff; --clr-magenta: #ff00ff; --clr-deeppink: #ff0080; --base-color: #131417; --line-color: #ffffff; } body { display: flex; justify-content: center; align-items: center; height: 100vh; padding: 0; margin: 0; overflow: hidden; font-family: Arial, Helvetica, sans-serif; padding-top: 1em; background: var(--base-color); } *, *:before, *:after { box-sizing: border-box; } *:before, *:after { position: absolute; } h1 { position: absolute; top: 0; padding: 0.3em; font-weight: normal; text-transform: capitalize; font-size: 2em; color: #ffffff80; width: 16em; text-align: center; margin: 0; text-shadow: 1px 1px 1px #00000045, 0px 0px 1px var(--line-color); } h1 span { color: #ff0000; text-shadow: 0 0 5px #ff0000, 0 0 3px #ff0000; } h1 span + span { color: #00ff00; text-shadow: 0 0 5px #00ff00, 0 0 3px #00ff00; } h1 span + span + span { color: #002bff; text-shadow: 0 0 5px #002bff, 0 0 3px #002bff; } input { display: none; } .wheel { width: 600px; height: 600px; background-image: none; border-radius: 100%; transition: all 1s ease 0s; margin-top: 3em; background: radial-gradient( var(--base-color) 0, var(--base-color) 33%, transparent 33.5%, transparent 100% ), radial-gradient( transparent 0, transparent 45%, var(--base-color) 45.25%, var(--base-color) 45.75%, transparent 46%, transparent 58%, var(--base-color) 58.25%, var(--base-color) 58.75%, transparent 59%, transparent 100% ), radial-gradient( #ffffff80 45.5%, #ffffff50 45.5%, #ffffff50 58.5%, transparent 45.5%, transparent 100% ), conic-gradient( from -15deg, var(--clr-red) 0deg, var(--clr-red) 30deg, var(--clr-darkorange) 30deg, var(--clr-darkorange) 60deg, var(--clr-yellow) 60deg, var(--clr-yellow) 90deg, var(--clr-chartreuse) 90deg, var(--clr-chartreuse) 120deg, var(--clr-green) 120deg, var(--clr-green) 150deg, var(--clr-springgreen) 150deg, var(--clr-springgreen) 180deg, var(--clr-cyan) 180deg, var(--clr-cyan) 210deg, var(--clr-dodgerblue) 210deg, var(--clr-dodgerblue) 240deg, var(--clr-blue) 240deg, var(--clr-blue) 270deg, var(--clr-electricindigo) 270deg, var(--clr-electricindigo) 300deg, var(--clr-magenta) 300deg, var(--clr-magenta) 330deg, var(--clr-deeppink) 330deg, var(--clr-deeppink) 360deg ); } input#gradient:checked ~ .wheel { background: radial-gradient( var(--base-color) 0, var(--base-color) 33%, transparent 33.5%, transparent 100% ), radial-gradient( transparent 0, transparent 45%, var(--base-color) 45.25%, var(--base-color) 45.75%, transparent 46%, transparent 58%, var(--base-color) 58.25%, var(--base-color) 58.75%, transparent 59%, transparent 100% ), radial-gradient( #ffffff80 45.5%, #ffffff50 45.5%, #ffffff50 58.5%, transparent 45.5%, transparent 100% ), conic-gradient( from 0deg, var(--clr-red), var(--clr-darkorange), var(--clr-yellow), var(--clr-chartreuse), var(--clr-green), var(--clr-springgreen), var(--clr-cyan), var(--clr-dodgerblue), var(--clr-blue), var(--clr-electricindigo), var(--clr-magenta), var(--clr-deeppink), var(--clr-red) ); } .wheel > div { width: 600px; padding: 0; position: absolute; top: 50%; transform-origin: center center; box-shadow: 0 0 1px 2px var(--base-color); } .wheel > div:nth-child(1) { transform: rotate(15deg); } .wheel > div:nth-child(2) { transform: rotate(45deg); } .wheel > div:nth-child(3) { transform: rotate(75deg); } .wheel > div:nth-child(4) { transform: rotate(105deg); } .wheel > div:nth-child(5) { transform: rotate(135deg); } .wheel > div:nth-child(6) { transform: rotate(165deg); } .arrows { background: var(--base-color); width: 280px; position: absolute; height: 280px; border-radius: 100%; z-index: 1; margin-top: 3em; z-index: 2; } .arrows:before { content: ""; border: 6px solid #fff; width: 2em; height: 2em; border-radius: 100%; left: 124px; top: 125px; background: #131417; z-index: 2; } .arrows > div { background: var(--line-color); width: 6px; position: absolute; height: 120px; z-index: 1; margin-top: 20px; left: 137px; transform-origin: center bottom; perspective: 10px; } .arrows > div:nth-child(2) { transform: rotate(120deg); } .arrows > div:nth-child(3) { transform: rotate(240deg); } .arrows > div:before { content: ""; border: 12px solid transparent; border-bottom: 20px solid var(--line-color); margin-top: -20px; margin-left: -9px; } .arrows > div:after { content: ""; border: 8px solid transparent; margin-top: -19px; margin-left: -47px; width: 100px; height: 36px; border-top-color: var(--line-color); border-radius: 100%; } .arrows div span { border: 10px solid transparent; width: 200px; height: 60px; position: absolute; border-top: 9px solid var(--line-color); border-radius: 100%; left: -97px; top: -191px; } .arrows div span:before, .arrows div span:after { content: ""; width: 8px; height: 178px; position: absolute; background: var(--line-color); transform: rotate(-15.25deg); transform-origin: left top; top: 5px; left: 2px; border-radius: 1px; } .arrows div span:after { transform: rotate(15.25deg); transform-origin: right top; left: 170px; top: 5px; } label { background: #607d8b; width: 2em; height: 2em; position: absolute; cursor: pointer; z-index: 1; border-radius: 3px; border: 2px solid rgba(0, 0, 0, 0.15); left: 1em; z-index: 3; opacity: 0.75; } label > span { font-size: 0.65em; text-transform: uppercase; padding: 0em 0em 0em 1em; float: left; margin-left: 3.05em; text-align: left; position: relative; height: 32px; display: flex; justify-content: left; align-items: center; margin-top: -2px; width: 9.45em; border-radius: 2px 0 0 2px; transition: all 0.5s ease 0s; } label > span:before { content: ""; border: 8px solid transparent; border-left: 10px solid #56565690; position: absolute; top: 0.7em; left: -1.5em; transition: left 0.18s ease 0s; } input:checked + label > span:before { left: -0.2em; transition: left 0.18s ease 0s; } input:checked + label, label:hover { opacity: 1; } input:checked + label span { background: #131417; transition: all 0.5s ease 0s; font-size: 0.75em; margin-left: 2.5em; width: 8.5em; padding-left: 1.4em; } label[for="c-red"] > span { color: var(--clr-red); } label[for="c-darkorange"] > span { color: var(--clr-darkorange); } label[for="c-yellow"] > span { color: var(--clr-yellow); } label[for="c-chartreuse"] > span { color: var(--clr-chartreuse); } label[for="c-green"] > span { color: var(--clr-green); } label[for="c-springgreen"] > span { color: var(--clr-springgreen); } label[for="c-cyan"] > span { color: var(--clr-cyan); } label[for="c-dodgerblue"] > span { color: var(--clr-dodgerblue); } label[for="c-blue"] > span { color: var(--clr-blue); } label[for="c-electricindigo"] > span { color: #822be2; } label[for="c-magenta"] > span { color: var(--clr-magenta); } label[for="c-deeppink"] > span { color: var(--clr-deeppink); } label[for="c-red"] > span:before { border-left-color: var(--clr-red); } label[for="c-darkorange"] > span:before { border-left-color: var(--clr-darkorange); } label[for="c-yellow"] > span:before { border-left-color: var(--clr-yellow); } label[for="c-chartreuse"] > span:before { border-left-color: var(--clr-chartreuse); } label[for="c-green"] > span:before { border-left-color: var(--clr-green); } label[for="c-springgreen"] > span:before { border-left-color: var(--clr-springgreen); } label[for="c-cyan"] > span:before { border-left-color: var(--clr-cyan); } label[for="c-dodgerblue"] > span:before { border-left-color: var(--clr-dodgerblue); } label[for="c-blue"] > span:before { border-left-color: var(--clr-blue); } label[for="c-electricindigo"] > span:before { border-left-color: #822be2; } label[for="c-magenta"] > span:before { border-left-color: var(--clr-magenta); } label[for="c-deeppink"] > span:before { border-left-color: var(--clr-deeppink); } input#c-red + label { top: 10.5vh; background: var(--clr-red); } input#c-darkorange + label { top: 18vh; background: var(--clr-darkorange); } input#c-yellow + label { top: 25.5vh; background: var(--clr-yellow); } input#c-chartreuse + label { top: 33vh; background: var(--clr-chartreuse); } input#c-green + label { top: 40.5vh; background: var(--clr-green); } input#c-springgreen + label { top: 48vh; background: var(--clr-springgreen); } input#c-cyan + label { top: 55.5vh; background: var(--clr-cyan); } input#c-dodgerblue + label { top: 63vh; background: var(--clr-dodgerblue); } input#c-blue + label { top: 70.5vh; background: var(--clr-blue); } input#c-electricindigo + label { top: 78vh; background: #822be2; } input#c-magenta + label { top: 85.5vh; background: var(--clr-magenta); } input#c-deeppink + label { top: 93vh; background: var(--clr-deeppink); } input#c-red:checked ~ .wheel { transform: rotate(0deg); } input#c-darkorange:checked ~ .wheel { transform: rotate(-30deg); } input#c-yellow:checked ~ .wheel { transform: rotate(-60deg); } input#c-chartreuse:checked ~ .wheel { transform: rotate(-90deg); } input#c-green:checked ~ .wheel { transform: rotate(-120deg); } input#c-springgreen:checked ~ .wheel { transform: rotate(-150deg); } input#c-cyan:checked ~ .wheel { transform: rotate(-180deg); } input#c-dodgerblue:checked ~ .wheel { transform: rotate(-210deg); } input#c-blue:checked ~ .wheel { transform: rotate(-240deg); } input#c-electricindigo:checked ~ .wheel { transform: rotate(-270deg); } input#c-magenta:checked ~ .wheel { transform: rotate(-300deg); } input#c-deeppink:checked ~ .wheel { transform: rotate(-330deg); } input#c-darkorange:checked ~ .demo .primary { background: var(--clr-darkorange); } input#c-darkorange:checked ~ .demo .secondary { background: var(--clr-springgreen); } input#c-darkorange:checked ~ .demo .secondary + .secondary { background: var(--clr-electricindigo); } input#c-yellow:checked ~ .demo .primary { background: var(--clr-yellow); } input#c-yellow:checked ~ .demo .secondary { background: var(--clr-cyan); } input#c-yellow:checked ~ .demo .secondary + .secondary { background: var(--clr-magenta); } input#c-chartreuse:checked ~ .demo .primary { background: var(--clr-chartreuse); } input#c-chartreuse:checked ~ .demo .secondary { background: var(--clr-dodgerblue); } input#c-chartreuse:checked ~ .demo .secondary + .secondary { background: var(--clr-deeppink); } input#c-green:checked ~ .demo .primary { background: var(--clr-green); } input#c-green:checked ~ .demo .secondary { background: var(--clr-blue); } input#c-green:checked ~ .demo .secondary + .secondary { background: var(--clr-red); } input#c-springgreen:checked ~ .demo .primary { background: var(--clr-springgreen); } input#c-springgreen:checked ~ .demo .secondary { background: var(--clr-electricindigo); } input#c-springgreen:checked ~ .demo .secondary + .secondary { background: var(--clr-darkorange); } input#c-cyan:checked ~ .demo .primary { background: var(--clr-cyan); } input#c-cyan:checked ~ .demo .secondary { background: var(--clr-magenta); } input#c-cyan:checked ~ .demo .secondary + .secondary { background: var(--clr-yellow); } input#c-dodgerblue:checked ~ .demo .primary { background: var(--clr-dodgerblue); } input#c-dodgerblue:checked ~ .demo .secondary { background: var(--clr-deeppink); } input#c-dodgerblue:checked ~ .demo .secondary + .secondary { background: var(--clr-chartreuse); } input#c-blue:checked ~ .demo .primary { background: var(--clr-blue); } input#c-blue:checked ~ .demo .secondary { background: var(--clr-red); } input#c-blue:checked ~ .demo .secondary + .secondary { background: var(--clr-green); } input#c-electricindigo:checked ~ .demo .primary { background: var(--clr-electricindigo); } input#c-electricindigo:checked ~ .demo .secondary { background: var(--clr-darkorange); } input#c-electricindigo:checked ~ .demo .secondary + .secondary { background: var(--clr-springgreen); } input#c-magenta:checked ~ .demo .primary { background: var(--clr-magenta); } input#c-magenta:checked ~ .demo .secondary { background: var(--clr-yellow); } input#c-magenta:checked ~ .demo .secondary + .secondary { background: var(--clr-cyan); } input#c-deeppink:checked ~ .demo .primary { background: var(--clr-deeppink); } input#c-deeppink:checked ~ .demo .secondary { background: var(--clr-chartreuse); } input#c-deeppink:checked ~ .demo .secondary + .secondary { background: var(--clr-dodgerblue); } input#c-darkorange:checked ~ .demo .primary:before { content: "dark orange"; } input#c-darkorange:checked ~ .demo .secondary:before { content: "spring green"; } input#c-darkorange:checked ~ .demo .secondary + .secondary:before { content: "electric indigo"; } input#c-yellow:checked ~ .demo .primary:before { content: "ye.........完整代码请登录后点击上方下载按钮下载查看
网友评论0