css美化radio标签实现滑动式单选效果代码
代码语言:html
所属分类:表单美化
代码描述:css美化radio标签实现滑动式单选效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; background-color: #0050B7; } fieldset { border: none; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 100%; height: 55px; width: fit-content; background-color: rgba(0, 0, 0, 0.35); padding: 6px; border-radius: 10px; gap: 4px; --active: 0; } fieldset:has(label:nth-child(2) input:checked) { --active: 1; } fieldset:has(label:nth-child(3) input:checked) { --active: 2; } fieldset .selector { grid-area: 1/1/2/2; height: 100%; width: 100%; border-radius: 6px; position: relative; pointer-events: none; } fieldset .selector::before, fieldset .selector::after { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #fff; border-radius: inherit; transform: translateX(calc(var(--active) * (100% + 4px))); transition: 0.4s transform cubic-bezier(0.28, 1.33, 0.64, 1); } fieldset .selector::before { transition-delay: 0.05s; } label { position: relative; z-index: 1; cursor: pointer; } label:nth-child(1) { grid-area: 1/1/2/2; } label:nth-child(2) { grid-area: 1/2/2/3; } label:nth-child(3) { grid-area: 1/3/2/4; } label input { position: abso.........完整代码请登录后点击上方下载按钮下载查看
网友评论0