radio卡片选择框选择效果代码
代码语言:html
所属分类:表单美化
代码描述:radio卡片选择框选择效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --card-line-height: 1.2em; --card-padding: 1em; --card-radius: 0.5em; --color-green: #558309; --color-gray: #e2ebf6; --color-dark-gray: #c4d1e1; --radio-border-width: 2px; --radio-size: 1.5em; } body { background-color: #f2f8ff; color: #263238; font-family: 'Noto Sans', sans-serif; margin: 0; padding: 2em 6vw; } .grid { display: grid; grid-gap: var(--card-padding); margin: 0 auto; max-width: 60em; padding: 0; } @media (min-width: 42em) { .grid { grid-template-columns: repeat(3, 1fr); } } .card { background-color: #fff; border-radius: var(--card-radius); position: relative; } .card:hover { box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.15); } .radio { font-size: inherit; margin: 0; position: absolute; right: calc(var(--card-padding) + var(--radio-border-width)); top: calc(var(--card-padding) + var(--radio-border-width)); } @supports (-webkit-appearance: none) or (-moz-appearance: none) { .radio { -webkit-appearance: none; -moz-appearance: none; background: #fff; border: var(--radio-border-width) solid var(--color-gray); border-radius: 50%; cursor: pointer; height: var(--radio-size); outline: none; transition: background 0.2s ease-out, border-color 0.2s ease-out; width: var(--radio-size); } .radio::after { border: var(--radio-border-width) solid #fff; border-top: 0; border-left: 0; content: ''; display: block; height: 0.75rem; left: 25%; position: absolute; top: 50%; transform: rotate(45deg) translate(-50%, -50%); width: 0.375rem; } .radio:checked { background: var(--color-green); border-color: var(--color-green); } .card:hover .radio { border-color: var(--color-dark-gray); } .card:hover .radio:checked { border-color: var(--color-green); } } .plan-details { border: var(--radio-border-width) solid var(--color-gray); border-radius: var(--card-radius); cursor: pointer; display: flex; flex-direction: column; padding: var(--card-padding); transition: border-color 0.2s ease-out; } .card:hover .plan-details { border-color: var(--color-dark-gray); } .radio:checked ~ .plan-details { border-color: var(--color-green); } .radio:focus ~ .plan-details { box-shadow: 0 0 0 2px var(--color-dark-gray); } .radio:disabled ~ .plan-details { color: var(--color-dark-gray); cursor: default; } .radio:disabled ~ .plan-details .plan-type { color: var(--color-dark-gray); } .card:hover .radio:disabled ~ .plan-details { border-color: var(--color-gray); box-shadow: none; } .card:hover .radio:disabled { bor.........完整代码请登录后点击上方下载按钮下载查看
网友评论0