码迷,mamicode.com
首页 > 移动开发 > 详细

css3 手机开关按钮 transition gradient

时间:2015-05-15 17:23:30      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

Css:

div { 
            width: 100px;
            margin: 0 auto;
        }
        .onoff { 
            display: inline-block;
            position: relative;
            width: 60px; 
            height: 20px; 
            overflow: hidden;
            border-radius: 10px; 
            border: 1px solid #909090; 
        }
        .onoff label {
            display: inline-block;
            position: relative;
            width: 100px;
            height: 20px;
            background-image: -webkit-linear-gradient(top, #fe7e02, #fea651);
            cursor: pointer;
        }
        .onoff label:before {
            content: "";
            display: inline-block;
            width: 2px;
            height: 10px;
            position: absolute;
            left: 22px;
            margin-top: 5px;
            overflow: hidden;
            background: #fff;
        }
        .onoff label:after {
            position: relative;
            z-index: 1;
            content: "";
            display: inline-block;
            margin-left: 39px;
            margin-top: -1px;
            width: 20px;
            height: 20px;
            border-radius: 10px;
            border: 1px solid #909090;
            background-image: -webkit-linear-gradient(top, #ddd, #fff); 
        }
        .onoff i {
            display: inline-block;
            position: absolute;
            z-index: 0;
            right: 0;
            top: 0px;
            width: 50px;
            height: 20px;
            background-image: -webkit-linear-gradient(top, #ddd, #fff);
        }
        .onoff i:after {
            content: "";
            display: inline-block;
            width: 8px;
            height: 8px;
            margin-left: 23px;
            border-radius: 5px;
            border: 1px solid #909090;
        }
        .onoff label {
            -webkit-transition: all .5s ease-out;
        }
        .onoff:hover label{
            margin-left: -40px;
        }

Html:

<div><span class="onoff"><label><i></i></label></span></div>

 截图:

技术分享

 

css3 手机开关按钮 transition gradient

标签:

原文地址:http://www.cnblogs.com/do-it/p/4506273.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!