radio checkbox点击美化动画效果
代码语言:html
所属分类:表单美化
代码描述:radio checkbox点击美化动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Hind:wght@400;700&display=swap'> <style> * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --bg: #e3e4e8; --fg: #17181c; --inputBg: #ffffff; --inputBgDown: #e3e4e8; --inputBorder: #c7cad1; --inputBorderDown: #c7cad1; --primary: #255ff4; --primaryDown: #5583f6; --duration: 0.5s; font-size: calc(20px + (30 - 20)*(100vw - 320px)/(1280 - 320)); } body, input { font: 1em/1.5 Hind, sans-serif; } body, label { display: flex; } body { background: var(--bg); color: var(--fg); height: 100vh; } form { margin: auto; } label, input { cursor: pointer; } input { margin-right: 0.5em; width: 1.5em; height: 1.5em; -webkit-appearance: none; appearance: none; } input:focus { outline: transparent; } input[type=checkbox], input[type=checkbox]:after, input[type=radio] { transition: all 0.1s linear; } input[type=checkbox] { background: var(--inputBg); border-radius: 0.25em; box-shadow: 0 0 0 0.1em var(--inputBorder) inset; } input[type=checkbox]:after { color: #255ff4; content: "\2713"; display: block; font-size: 1.5em; line-height: 1; text-align: center; transform: scale(0); transform-origin: 50% 67%; width: 100%; height: 100%; } input[type=checkbox]:checked { animation: popOutCheckbox var(--duration) linear; } input[type=checkbox]:checked:after { transform: scale(1); transition: background 0.1s linear, color 0.1s linear, transform calc(var(--duration) / 5) calc(var(--duration) / 2) linear; } input[type=checkbox]:active, input[type=checkbox]:focus { background: var(--inputBgDown); box-shadow: 0 0 0 0.1em var(--inputBorderDown) inset; } input[type=checkbox]:active:after, input[type=checkbox]:focus:after { color: var(--primaryDown); } input[type=radio] { background: var(--primary); border-radius: 50%; box-shadow: 0 0 0 0.1em var(--inputBorder) inset, 0 0 0 0.76em var(--inputBg) inset; } input[type=radio]:checked { animation: popOutRadio var(--duration) linear; box-shadow: 0 0 0 0.1em var(--inputBorder) inset, 0 0 0 0.375em var(--inputBg) inset; } input[type=radio]:active, input[type=radio]:focus { background: var(--primaryDown); box-shadow: 0 0 0 0.1em var(--inputBorderDown) inset, 0 0 0 0.76em var(--inputBgDown) inset; } input[type=radio]:checked:active, input[type=radio]:checked:focus { box-shadow: 0 0 0 0.1em var(--inputBorderDown) inset, 0 0 0 0.375em var(--inputBgDown) inset; } label { align-items: center; margin: 0.75em 0; position: relative; -webkit-tap-highlight-color: transparent; } label span { border-radius: 50%; display: block; pointer-events: none; position: absolute; top: 0.5em; left: 0.5em; width: 0.5em; height: 0.5em; transform: scale(0); } label span:nth-of-type(even) { top: 0.625em; left: 0.625em; width: 0.25em; height: 0.25em; } /* Animations */ @keyframes popOutCheckbox { from { background: transparent; border-radius: 50%; box-shadow: 0 0 0 0.375em var(--primary), 0 0 0 0.76em var(--primary) inset; transform: scale(0); } 25% { background: transparent; border-radius: 50%; box-shadow: 0 0 0 0.375em #db0bdb, 0 0 0 0.375em #db0bdb inset; transform: scale(1); } 50% { background: transparent; border-radius: 50%; box-shadow: 0 0 0 0 #db0b0b, 0 0 0 0 #db0b0b inset; transform: scale(1); } 50.1% { background: var(--inputBg); border-radius: 0.25em; box-shadow: 0 0 0 0 var(--primary), 0 0 0 0.1em var(--inputBorder) inset; transform: scale(0); } 75% { background: var(--inputBg); border-radius: 0.25em; box-shadow: 0 0 0 0 var(--primary), 0 0 0 0.1em var(--inputBorder) inset; transform: scale(1.1); } 87.5% { background: var(--inputBg); border-radius: 0.25em; box-shadow: 0 0 0 0 var(--primary), 0 0 0 0.1em var(--inputBorder) inset; transform: scale(0.95); } to { background: var(--inputBg); border-radius: 0.25em; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0