css中单选按钮怎么写,CSS3 拟物风格的单选按钮

CSS

语言:

CSSSCSS

确定

section {

counter-reset: total;

}

input {

opacity: 0;

position: absolute;

}

label {

position: relative;

display: block;

background: #f8f8f8;

border: 1px solid #f0f0f0;

border-radius: 2em;

padding: 0.5em 1em 0.5em 5em;

box-shadow: 0 1px 2px rgba(100, 100, 100, 0.5) inset, 0 0 10px rgba(100, 100, 100, 0.1) inset;

cursor: pointer;

text-shadow: 0 2px 2px #fff;

}

label::before {

content: '';

position: absolute;

top: 50%;

left: 0.7em;

width: 3em;

height: 1.2em;

border-radius: 0.6em;

background: #eee;

-webkit-transform: translateY(-50%);

-ms-transform: translateY(-50%);

transform: translateY(-50%);

box-shadow: 0 1px 3px rgba(100, 100, 100, 0.5) inset, 0 0 10px rgba(100, 100, 100, 0.2) inset;

}

label::after {

content: '';

position: absolute;

top: 50%;

left: 0.5em;

width: 1.4em;

height: 1.4em;

border: 0.25em solid #fafafa;

border-radius: 50%;

box-sizing: border-box;

background-color: #ddd;

background-image: -webkit-linear-gradient(bottom, #fff 0%, #fff 40%, transparent 100%);

background-image: linear-gradient(to top, #fff 0%, #fff 40%, transparent 100%);

-webkit-transform: translateY(-50%);

-ms-transform: translateY(-50%);

transform: translateY(-50%);

box-shadow: 0 3px 3px rgba(0, 0, 0, 0.5);

}

label,

label::before,

label::after {

-webkit-transition: all 0.2s ease-out;

transition: all 0.2s ease-out;

}

label:hover,

input:focus + label {

color: black;

}

label:hover::after,

input:focus + label::after {

background-color: #ccc;

box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);

}

input:checked {

counter-increment: total;

}

input:checked + label::before {

background: #4ce355;

}

input:checked + label::after {

-webkit-transform: translateX(2em) translateY(-50%);

-ms-transform: translateX(2em) translateY(-50%);

transform: translateX(2em) translateY(-50%);

}

.total::after {

content: counter(total);

font-weight: bold;

/* misc */

}

html,

body {

height: 100%;

}

body {

display: -webkit-box;

display: -webkit-flex;

display: -ms-flexbox;

display: flex;

background: #eee;

}

section {

margin: auto;

padding: 2em;

background: white;

box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);

}

div {

margin: 1em 0;

font: 1.5em/1.4 "open sans condensed";

color: #777;

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值