html 复选框美化,HTML5&CSS3的CheckBox美化案例

属性介绍:transition (过渡效果)

transition-property 规定所设置的CSS过渡名称

transition-duration 设置过渡所需要的时间 如果设置为0则没有效果

transition-timing-function 设置过渡效果的速度曲线

transition-delay 定义过渡效果何时开始

transition: all 0 ease 0 //默认属性

transition-timing-function 属性描述

描述

linear

规定以相同速度开始至结束的过渡效果(等于 cubic-bezier(0,0,1,1))。

ease

规定慢速开始,然后变快,然后慢速结束的过渡效果(cubic-bezier(0.25,0.1,0.25,1))。

ease-in

规定以慢速开始的过渡效果(等于 cubic-bezier(0.42,0,1,1))。

ease-out

规定以慢速开始和结束的过渡效果(等于 cubic-bezier(0.42,0,0.58,1))。

cubic-bezier(n,n,n,n)

在 cubic-bezier 函数中定义自己的值。可能的值是 0 至 1 之间的数值。

公共CSS样式代码

//隐藏Type属性为checkbox的input框

input[type=checkbox] {

visibility: hidden;

}

样式一

/* 第一种样式 */

.checkboxOne {//制作一个横条

width: 40px;

height: 10px;

background: #555;

margin: 20px 80px;

position: relative;

border-radius: 3px;

}

/**

* Create the slider from the label

*/

.checkboxOne label {

display: block;//定义为块级元素

width: 16px;

height: 16px;

border-radius: 50%;

-webkit-transition: all .5s ease;

-moz-transition: all .5s ease;

-o-transition: all .5s ease;

-ms-transition: all .5s ease;

transition: all .5s ease;//设置滑块动作的速度

cursor: pointer;

position: absolute;//绝对定位

top: -3px;

left: -3px;

background: #ccc;

}

/**

* Move the slider in the correct position if the checkbox is clicked

*/

.checkboxOne input[type=checkbox]:checked + label {

left: 27px;//设置label滑块移动的距离

}

HTML代码

通过label的for属性与checkbox进行绑定实现选择功能

Checkbox One

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值