css 选择button,CSS自定义单选按钮

css

/* body */

body {

width: 100%;

min-height: 100vh;

display: flex;

justify-content: center;

align-items: center;

margin: 0;

padding: 0;

font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;

}

/* section */

section {

width: 50%;

min-height: inherit;

display: flex;

justify-content: center;

align-items: center;

flex-direction: column;

position: relative;

}

section::before,

section::after {

content: "";

display: block;

border-radius: 100%;

position: absolute;

}

section::before {

width: 30px;

height: 30px;

background: var(--primary);

-webkit-clip-path: polygon(0 100%, 100% 0, 100% 100%);

clip-path: polygon(0 100%, 100% 0, 100% 100%);

top: 18px;

left: 18px;

}

section::after {

width: 42px;

height: 42px;

border: 1px solid var(--primary);

top: 11px;

left: 11px;

}

.light {

--primary: hsl(250, 100%, 44%);

--other: hsl(0, 0%, 14%);

background: hsl(0, 0%, 98%);

}

.dark {

--primary: hsl(1, 100%, 68%);

--other: hsl(0, 0%, 90%);

background: hsl(0, 0%, 10%);

}

/* h1 */

h1 {

color: var(--other);

padding: 8px 4px;

border-bottom: 2px solid var(--other);

}

/* label */

label {

display: flex;

justify-content: flex-start;

align-items: center;

flex-wrap: nowrap;

margin: 12px 0;

cursor: pointer;

position: relative;

}

/* input */

input {

opacity: 0;

position: absolute;

left: 50%;

top: 50%;

-webkit-transform: translate(-50%, -50%);

transform: translate(-50%, -50%);

z-index: -1;

}

/* .design */

.design {

width: 16px;

height: 16px;

border: 1px solid var(--other);

border-radius: 100%;

margin-right: 16px;

position: relative;

}

.design::before,

.design::after {

content: "";

display: block;

width: inherit;

height: inherit;

border-radius: inherit;

position: absolute;

-webkit-transform: scale(0);

transform: scale(0);

-webkit-transform-origin: center center;

transform-origin: center center;

}

.design:before {

background: var(--other);

opacity: 0;

transition: .3s;

}

.design::after {

background: var(--primary);

opacity: .4;

transition: .6s;

}

/* .text */

.text {

color: var(--other);

font-weight: bold;

}

/* checked state */

input:checked+.design::before {

opacity: 1;

-webkit-transform: scale(.6);

transform: scale(.6);

}

/* other states */

input:hover+.design,

input:focus+.design {

border: 1px solid var(--primary);

}

input:hover+.design:before,

input:focus+.design:before {

background: var(--primary);

}

input:hover~.text {

color: var(--primary);

}

input:focus+.design::after,

input:active+.design::after {

opacity: .1;

-webkit-transform: scale(2.6);

transform: scale(2.6);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值