html自定义单选框按钮,CSS3 自定义样式的单选框按钮

CSS

语言:

CSSSCSS

确定

* {

-webkit-box-sizing: border-box;

-moz-box-sizing: border-box;

box-sizing: border-box;

}

html,

body {

height: 100%;

}

html {

background: #444;

background: -webkit-radial-gradient(center, circle, #666, #222);

background: radial-gradient(circle at center, #666, #222);

}

body {

min-height: 100%;

overflow: hidden;

}

.wrap {

height: 100%;

min-height: 100%;

margin: 0 auto;

}

.buttons-wrap {

position: relative;

text-align: center;

top: 50%;

margin-top: -35px;

}

.button-label {

display: inline-block;

padding: 14px 30px;

margin: 10px 5px;

cursor: pointer;

color: #737373;

text-shadow: 0 -1px 0 white;

border: 1px solid #737373;

font-size: 20px;

font-family: "Lato", sans-serif;

font-weight: 900;

border-radius: 4px;

background: #eee;

background: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#ccc));

background: -webkit-linear-gradient(#fefefe, #ccc);

background: linear-gradient(#fefefe, #ccc);

-webkit-box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 -3px 0 rgba(0, 0, 0, 0.22);

box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 -3px 0 rgba(0, 0, 0, 0.22);

-webkit-transition: 0.1s;

transition: 0.1s;

-webkit-touch-callout: none;

-webkit-user-select: none;

-moz-user-select: none;

-ms-user-select: none;

user-select: none;

}

.button-label:hover {

background: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#e5e5e5));

background: -webkit-linear-gradient(#fefefe, #e5e5e5);

background: linear-gradient(#fefefe, #e5e5e5);

}

.button-label:active {

-webkit-transform: translateY(2px);

-ms-transform: translateY(2px);

transform: translateY(2px);

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

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

}

#yes-button:checked + .button-label {

background: #a1d122;

background: -webkit-radial-gradient(center, circle, #9bd500, #a1d122);

background: radial-gradient(circle at center, #9bd500, #a1d122);

color: white;

text-shadow: 0 1px 0 #737373;

border-color: #7fa51b;

}

#no-button:checked + .button-label {

background: -webkit-radial-gradient(center, circle, #e60000, #c00);

background: radial-gradient(circle at center, #e60000, #c00);

color: white;

text-shadow: 0 1px 0 #737373;

border-color: #900;

}

.hidden {

display: none;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用如下的 HTMLCSS 代码创建一个类似 Element UI 单选框按钮样式HTML 代码: ```html <label class="radio-btn"> <input type="radio" name="radio-group" value="option-1"> <span class="radio-btn-label">Option 1</span> </label> <label class="radio-btn"> <input type="radio" name="radio-group" value="option-2"> <span class="radio-btn-label">Option 2</span> </label> <label class="radio-btn"> <input type="radio" name="radio-group" value="option-3"> <span class="radio-btn-label">Option 3</span> </label> ``` CSS 代码: ```css .radio-btn { display: inline-block; margin-right: 20px; position: relative; } .radio-btn input[type="radio"] { position: absolute; opacity: 0; } .radio-btn-label { display: inline-block; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #ccc; position: relative; cursor: pointer; vertical-align: middle; margin-right: 8px; } .radio-btn input[type="radio"]:checked + .radio-btn-label:after { content: ''; display: block; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 12px; height: 12px; border-radius: 50%; background: #007aff; } ``` 这段代码将会创建 3 个单选框按钮,每个按钮都由一个 label 和两个元素 (input 和 span) 组成。其中,input 元素用来获取用户择,而 span 元素包含了 label 的文本内容。 要自定义按钮样式,你可以修改 .radio-btn-label 和 .radio-btn input[type="radio"]:checked + .radio-btn-label:after 这两个 CSS 类。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值